From acf17905ed7290bb4c5a36c3fe603eeb28424fa5 Mon Sep 17 00:00:00 2001 From: wandererfan Date: Tue, 23 Aug 2022 15:32:13 -0400 Subject: [PATCH] [TD]CI clang warnings --- src/Mod/TechDraw/App/AppTechDrawPy.cpp | 422 +++++---- src/Mod/TechDraw/App/ArrowPropEnum.h | 4 +- src/Mod/TechDraw/App/CenterLinePyImp.cpp | 844 +++++++++--------- src/Mod/TechDraw/App/Cosmetic.cpp | 172 ++-- src/Mod/TechDraw/App/Cosmetic.h | 9 +- src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp | 20 +- src/Mod/TechDraw/App/CosmeticExtension.cpp | 40 +- src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp | 4 +- src/Mod/TechDraw/App/DrawDimHelper.cpp | 12 +- src/Mod/TechDraw/App/DrawDimHelper.h | 6 +- src/Mod/TechDraw/App/DrawGeomHatch.cpp | 94 +- src/Mod/TechDraw/App/DrawGeomHatch.h | 6 +- src/Mod/TechDraw/App/DrawHatch.cpp | 16 +- src/Mod/TechDraw/App/DrawHatch.h | 10 +- src/Mod/TechDraw/App/DrawLeaderLine.cpp | 40 +- src/Mod/TechDraw/App/DrawLeaderLine.h | 8 +- src/Mod/TechDraw/App/DrawPage.cpp | 28 +- src/Mod/TechDraw/App/DrawPage.h | 12 +- src/Mod/TechDraw/App/DrawPagePyImp.cpp | 4 +- .../TechDraw/App/DrawParametricTemplate.cpp | 4 +- src/Mod/TechDraw/App/DrawParametricTemplate.h | 4 +- .../App/DrawParametricTemplatePyImp.cpp | 2 +- src/Mod/TechDraw/App/DrawProjGroup.cpp | 98 +- src/Mod/TechDraw/App/DrawProjGroup.h | 17 +- src/Mod/TechDraw/App/DrawProjGroupItem.cpp | 48 +- src/Mod/TechDraw/App/DrawProjGroupItem.h | 9 +- src/Mod/TechDraw/App/DrawProjectSplit.cpp | 64 +- src/Mod/TechDraw/App/DrawProjectSplit.h | 8 +- src/Mod/TechDraw/App/DrawRichAnno.cpp | 18 +- src/Mod/TechDraw/App/DrawRichAnno.h | 8 +- src/Mod/TechDraw/App/DrawSVGTemplate.cpp | 8 +- src/Mod/TechDraw/App/DrawSVGTemplate.h | 6 +- src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp | 4 +- src/Mod/TechDraw/App/DrawTemplate.cpp | 2 +- src/Mod/TechDraw/App/DrawTemplate.h | 6 +- src/Mod/TechDraw/App/DrawTile.cpp | 8 +- src/Mod/TechDraw/App/DrawTile.h | 6 +- src/Mod/TechDraw/App/DrawTileWeld.cpp | 10 +- src/Mod/TechDraw/App/DrawTileWeld.h | 6 +- src/Mod/TechDraw/App/DrawUtil.cpp | 182 ++-- src/Mod/TechDraw/App/DrawUtil.h | 16 +- src/Mod/TechDraw/App/DrawView.cpp | 97 +- src/Mod/TechDraw/App/DrawView.h | 4 +- src/Mod/TechDraw/App/DrawViewAnnotation.cpp | 26 +- src/Mod/TechDraw/App/DrawViewAnnotation.h | 6 +- src/Mod/TechDraw/App/DrawViewArch.cpp | 54 +- src/Mod/TechDraw/App/DrawViewArch.h | 8 +- src/Mod/TechDraw/App/DrawViewBalloon.cpp | 18 +- src/Mod/TechDraw/App/DrawViewBalloon.h | 8 +- src/Mod/TechDraw/App/DrawViewClip.cpp | 22 +- src/Mod/TechDraw/App/DrawViewClip.h | 8 +- src/Mod/TechDraw/App/DrawViewClipPyImp.cpp | 8 +- src/Mod/TechDraw/App/DrawViewCollection.cpp | 6 +- src/Mod/TechDraw/App/DrawViewCollection.h | 6 +- src/Mod/TechDraw/App/DrawViewDetail.cpp | 38 +- src/Mod/TechDraw/App/DrawViewDetail.h | 4 +- src/Mod/TechDraw/App/DrawViewDimExtent.cpp | 26 +- src/Mod/TechDraw/App/DrawViewDimExtent.h | 6 +- src/Mod/TechDraw/App/DrawViewDimension.cpp | 226 ++--- src/Mod/TechDraw/App/DrawViewDimension.h | 26 +- src/Mod/TechDraw/App/DrawViewDraft.cpp | 48 +- src/Mod/TechDraw/App/DrawViewDraft.h | 6 +- src/Mod/TechDraw/App/DrawViewImage.cpp | 14 +- src/Mod/TechDraw/App/DrawViewImage.h | 6 +- src/Mod/TechDraw/App/DrawViewMulti.cpp | 18 +- src/Mod/TechDraw/App/DrawViewMulti.h | 6 +- src/Mod/TechDraw/App/DrawViewPart.cpp | 147 ++- src/Mod/TechDraw/App/DrawViewPart.h | 9 +- src/Mod/TechDraw/App/DrawViewPartPyImp.cpp | 24 +- src/Mod/TechDraw/App/DrawViewSection.cpp | 64 +- src/Mod/TechDraw/App/DrawViewSection.h | 4 +- src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp | 38 +- src/Mod/TechDraw/App/DrawViewSpreadsheet.h | 4 +- src/Mod/TechDraw/App/DrawViewSymbol.cpp | 10 +- src/Mod/TechDraw/App/DrawViewSymbol.h | 4 +- src/Mod/TechDraw/App/DrawViewSymbolPyImp.cpp | 2 +- src/Mod/TechDraw/App/DrawWeldSymbol.cpp | 16 +- src/Mod/TechDraw/App/DrawWeldSymbol.h | 8 +- src/Mod/TechDraw/App/EdgeWalker.cpp | 50 +- src/Mod/TechDraw/App/EdgeWalker.h | 4 +- src/Mod/TechDraw/App/FeatureProjection.cpp | 24 +- src/Mod/TechDraw/App/Geometry.cpp | 228 ++--- src/Mod/TechDraw/App/Geometry.h | 10 +- src/Mod/TechDraw/App/GeometryObject.cpp | 96 +- src/Mod/TechDraw/App/GeometryObject.h | 8 +- src/Mod/TechDraw/App/HatchLine.cpp | 90 +- src/Mod/TechDraw/App/HatchLine.h | 8 +- src/Mod/TechDraw/App/LandmarkDimension.cpp | 20 +- src/Mod/TechDraw/App/LandmarkDimension.h | 6 +- src/Mod/TechDraw/App/LineGroup.cpp | 24 +- src/Mod/TechDraw/App/LineGroup.h | 4 +- src/Mod/TechDraw/App/Preferences.cpp | 10 +- src/Mod/TechDraw/App/Preferences.h | 4 +- src/Mod/TechDraw/App/ProjectionAlgos.cpp | 44 +- src/Mod/TechDraw/App/ProjectionAlgos.h | 9 +- .../TechDraw/App/PropertyCenterLineList.cpp | 6 +- src/Mod/TechDraw/App/PropertyCenterLineList.h | 4 +- .../TechDraw/App/PropertyCosmeticEdgeList.cpp | 4 +- .../TechDraw/App/PropertyCosmeticEdgeList.h | 4 +- .../App/PropertyCosmeticVertexList.cpp | 4 +- .../TechDraw/App/PropertyCosmeticVertexList.h | 4 +- .../TechDraw/App/PropertyGeomFormatList.cpp | 4 +- src/Mod/TechDraw/App/PropertyGeomFormatList.h | 4 +- src/Mod/TechDraw/App/QDomNodeModel.cpp | 4 +- src/Mod/TechDraw/App/QDomNodeModel.h | 6 +- src/Mod/TechDraw/App/ShapeExtractor.cpp | 6 +- src/Mod/TechDraw/App/ShapeExtractor.h | 6 +- src/Mod/TechDraw/App/TechDrawExport.cpp | 108 +-- src/Mod/TechDraw/Gui/AppTechDrawGui.cpp | 2 +- src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp | 58 +- src/Mod/TechDraw/Gui/Command.cpp | 56 +- src/Mod/TechDraw/Gui/CommandAnnotate.cpp | 55 +- src/Mod/TechDraw/Gui/CommandCreateDims.cpp | 106 +-- src/Mod/TechDraw/Gui/CommandDecorate.cpp | 18 +- src/Mod/TechDraw/Gui/CommandExtensionDims.cpp | 4 +- src/Mod/TechDraw/Gui/CommandExtensionPack.cpp | 4 +- src/Mod/TechDraw/Gui/DlgPageChooser.h | 1 - .../Gui/DlgPrefsTechDrawAdvancedImp.cpp | 2 +- .../Gui/DlgPrefsTechDrawDimensionsImp.cpp | 2 +- .../Gui/DlgPrefsTechDrawGeneralImp.cpp | 4 +- .../TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp | 2 +- src/Mod/TechDraw/Gui/DrawGuiUtil.cpp | 2 +- src/Mod/TechDraw/Gui/DrawGuiUtil.h | 8 +- src/Mod/TechDraw/Gui/Grabber3d.cpp | 24 +- src/Mod/TechDraw/Gui/Grabber3d.h | 10 +- src/Mod/TechDraw/Gui/MDIViewPage.cpp | 76 +- src/Mod/TechDraw/Gui/MDIViewPage.h | 26 +- src/Mod/TechDraw/Gui/PreCompiled.h | 2 +- src/Mod/TechDraw/Gui/PreferencesGui.cpp | 4 +- src/Mod/TechDraw/Gui/PreferencesGui.h | 4 +- src/Mod/TechDraw/Gui/QGCustomBorder.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomClip.cpp | 10 +- src/Mod/TechDraw/Gui/QGCustomLabel.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomRect.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomSvg.cpp | 2 +- src/Mod/TechDraw/Gui/QGCustomText.cpp | 14 +- src/Mod/TechDraw/Gui/QGCustomText.h | 2 +- src/Mod/TechDraw/Gui/QGDisplayArea.cpp | 2 +- src/Mod/TechDraw/Gui/QGEPath.cpp | 20 +- src/Mod/TechDraw/Gui/QGEPath.h | 47 +- src/Mod/TechDraw/Gui/QGIArrow.cpp | 122 +-- src/Mod/TechDraw/Gui/QGIArrow.h | 22 +- src/Mod/TechDraw/Gui/QGICMark.cpp | 10 +- src/Mod/TechDraw/Gui/QGICenterLine.cpp | 6 +- src/Mod/TechDraw/Gui/QGICenterLine.h | 2 +- src/Mod/TechDraw/Gui/QGIDecoration.cpp | 6 +- src/Mod/TechDraw/Gui/QGIEdge.cpp | 4 +- src/Mod/TechDraw/Gui/QGIEdge.h | 2 +- src/Mod/TechDraw/Gui/QGIFace.cpp | 88 +- src/Mod/TechDraw/Gui/QGIFace.h | 12 +- src/Mod/TechDraw/Gui/QGIGhostHighlight.cpp | 4 +- src/Mod/TechDraw/Gui/QGIHighlight.cpp | 12 +- src/Mod/TechDraw/Gui/QGIHighlight.h | 4 +- src/Mod/TechDraw/Gui/QGILeaderLine.cpp | 80 +- src/Mod/TechDraw/Gui/QGILeaderLine.h | 14 +- src/Mod/TechDraw/Gui/QGIMatting.cpp | 10 +- src/Mod/TechDraw/Gui/QGIPrimPath.cpp | 12 +- src/Mod/TechDraw/Gui/QGIProjGroup.cpp | 4 +- src/Mod/TechDraw/Gui/QGIRichAnno.cpp | 28 +- src/Mod/TechDraw/Gui/QGISVGTemplate.cpp | 2 +- src/Mod/TechDraw/Gui/QGISectionLine.cpp | 30 +- src/Mod/TechDraw/Gui/QGISectionLine.h | 4 +- src/Mod/TechDraw/Gui/QGITile.cpp | 28 +- src/Mod/TechDraw/Gui/QGIView.cpp | 109 +-- src/Mod/TechDraw/Gui/QGIView.h | 54 +- src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp | 8 +- src/Mod/TechDraw/Gui/QGIViewBalloon.cpp | 140 ++- src/Mod/TechDraw/Gui/QGIViewBalloon.h | 56 +- src/Mod/TechDraw/Gui/QGIViewClip.cpp | 24 +- src/Mod/TechDraw/Gui/QGIViewCollection.h | 6 +- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 228 +++-- src/Mod/TechDraw/Gui/QGIViewDimension.h | 97 +- src/Mod/TechDraw/Gui/QGIViewImage.cpp | 14 +- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 83 +- src/Mod/TechDraw/Gui/QGIViewPart.h | 8 +- src/Mod/TechDraw/Gui/QGIViewSection.cpp | 4 +- src/Mod/TechDraw/Gui/QGIViewSymbol.cpp | 8 +- src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp | 53 +- src/Mod/TechDraw/Gui/QGMText.cpp | 4 +- src/Mod/TechDraw/Gui/QGSPage.cpp | 131 ++- src/Mod/TechDraw/Gui/QGSPage.h | 67 +- src/Mod/TechDraw/Gui/QGTracker.cpp | 52 +- src/Mod/TechDraw/Gui/QGTracker.h | 8 + src/Mod/TechDraw/Gui/QGVNavStyle.cpp | 12 +- src/Mod/TechDraw/Gui/QGVPage.cpp | 62 +- src/Mod/TechDraw/Gui/QGVPage.h | 28 +- src/Mod/TechDraw/Gui/Rez.cpp | 10 +- src/Mod/TechDraw/Gui/TaskActiveView.cpp | 22 +- src/Mod/TechDraw/Gui/TaskActiveView.h | 2 - src/Mod/TechDraw/Gui/TaskBalloon.cpp | 24 +- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 23 +- src/Mod/TechDraw/Gui/TaskCenterLine.h | 45 +- src/Mod/TechDraw/Gui/TaskCosVertex.cpp | 27 +- src/Mod/TechDraw/Gui/TaskCosVertex.h | 30 +- src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp | 13 +- src/Mod/TechDraw/Gui/TaskCosmeticLine.h | 15 +- src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp | 6 +- src/Mod/TechDraw/Gui/TaskCustomizeFormat.h | 5 - src/Mod/TechDraw/Gui/TaskDetail.cpp | 69 +- src/Mod/TechDraw/Gui/TaskDetail.h | 50 +- src/Mod/TechDraw/Gui/TaskDimension.cpp | 64 +- src/Mod/TechDraw/Gui/TaskGeomHatch.cpp | 29 +- src/Mod/TechDraw/Gui/TaskGeomHatch.h | 47 +- src/Mod/TechDraw/Gui/TaskHatch.cpp | 8 +- src/Mod/TechDraw/Gui/TaskHatch.h | 4 - src/Mod/TechDraw/Gui/TaskLeaderLine.cpp | 82 +- src/Mod/TechDraw/Gui/TaskLeaderLine.h | 62 +- src/Mod/TechDraw/Gui/TaskLineDecor.cpp | 14 +- src/Mod/TechDraw/Gui/TaskLinkDim.cpp | 30 +- src/Mod/TechDraw/Gui/TaskLinkDim.h | 25 +- src/Mod/TechDraw/Gui/TaskProjGroup.cpp | 74 +- src/Mod/TechDraw/Gui/TaskProjGroup.h | 52 +- src/Mod/TechDraw/Gui/TaskProjection.cpp | 10 +- src/Mod/TechDraw/Gui/TaskRichAnno.cpp | 75 +- src/Mod/TechDraw/Gui/TaskRichAnno.h | 37 +- src/Mod/TechDraw/Gui/TaskSectionView.cpp | 101 +-- src/Mod/TechDraw/Gui/TaskSectionView.h | 44 +- .../TechDraw/Gui/TaskSelectLineAttributes.h | 6 - .../TechDraw/Gui/TaskSurfaceFinishSymbols.cpp | 119 ++- .../TechDraw/Gui/TaskSurfaceFinishSymbols.h | 37 +- src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp | 77 +- src/Mod/TechDraw/Gui/TaskWeldingSymbol.h | 28 +- src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp | 4 +- .../TechDraw/Gui/ViewProviderDimension.cpp | 10 +- .../TechDraw/Gui/ViewProviderDrawingView.cpp | 8 +- .../TechDraw/Gui/ViewProviderDrawingView.h | 4 +- .../TechDraw/Gui/ViewProviderGeomHatch.cpp | 8 +- src/Mod/TechDraw/Gui/ViewProviderHatch.cpp | 12 +- src/Mod/TechDraw/Gui/ViewProviderImage.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderLeader.cpp | 12 +- src/Mod/TechDraw/Gui/ViewProviderPage.cpp | 10 +- src/Mod/TechDraw/Gui/ViewProviderPage.h | 2 +- .../TechDraw/Gui/ViewProviderProjGroup.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp | 8 +- src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp | 2 +- src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp | 48 +- .../TechDraw/Gui/ViewProviderViewSection.cpp | 24 +- src/Mod/TechDraw/Gui/ViewProviderWeld.cpp | 8 +- src/Mod/TechDraw/Gui/ViewProviderWeld.h | 2 +- src/Mod/TechDraw/Gui/Workbench.h | 2 +- src/Mod/TechDraw/Gui/ZVALUE.h | 4 +- src/Mod/TechDraw/Gui/mrichtextedit.cpp | 118 +-- src/Mod/TechDraw/Gui/mrichtextedit.h | 73 +- src/Mod/TechDraw/Gui/mtextedit.cpp | 2 +- src/Mod/TechDraw/Gui/mtextedit.h | 4 +- 246 files changed, 3944 insertions(+), 4241 deletions(-) diff --git a/src/Mod/TechDraw/App/AppTechDrawPy.cpp b/src/Mod/TechDraw/App/AppTechDrawPy.cpp index 264a6105fa..2c8919ca02 100644 --- a/src/Mod/TechDraw/App/AppTechDrawPy.cpp +++ b/src/Mod/TechDraw/App/AppTechDrawPy.cpp @@ -133,59 +133,59 @@ class Module : public Py::ExtensionModule public: Module() : Py::ExtensionModule("TechDraw") { - add_varargs_method("edgeWalker",&Module::edgeWalker, - "[wires] = edgeWalker(edgePile,inclBiggest) -- Planar graph traversal finds wires in edge pile." + add_varargs_method("edgeWalker", &Module::edgeWalker, + "[wires] = edgeWalker(edgePile, inclBiggest) -- Planar graph traversal finds wires in edge pile." ); - add_varargs_method("findOuterWire",&Module::findOuterWire, + add_varargs_method("findOuterWire", &Module::findOuterWire, "wire = findOuterWire(edgeList) -- Planar graph traversal finds OuterWire in edge pile." ); - add_varargs_method("findShapeOutline",&Module::findShapeOutline, - "wire = findShapeOutline(shape,scale,direction) -- Project shape in direction and find outer wire of result." + add_varargs_method("findShapeOutline", &Module::findShapeOutline, + "wire = findShapeOutline(shape, scale, direction) -- Project shape in direction and find outer wire of result." ); - add_varargs_method("viewPartAsDxf",&Module::viewPartAsDxf, + add_varargs_method("viewPartAsDxf", &Module::viewPartAsDxf, "string = viewPartAsDxf(DrawViewPart) -- Return the edges of a DrawViewPart in Dxf format." ); - add_varargs_method("viewPartAsSvg",&Module::viewPartAsSvg, + add_varargs_method("viewPartAsSvg", &Module::viewPartAsSvg, "string = viewPartAsSvg(DrawViewPart) -- Return the edges of a DrawViewPart in Svg format." ); - add_varargs_method("writeDXFView",&Module::writeDXFView, - "writeDXFView(view,filename): Exports a DrawViewPart to a DXF file." + add_varargs_method("writeDXFView", &Module::writeDXFView, + "writeDXFView(view, filename): Exports a DrawViewPart to a DXF file." ); - add_varargs_method("writeDXFPage",&Module::writeDXFPage, - "writeDXFPage(page,filename): Exports a DrawPage to a DXF file." + add_varargs_method("writeDXFPage", &Module::writeDXFPage, + "writeDXFPage(page, filename): Exports a DrawPage to a DXF file." ); - add_varargs_method("findCentroid",&Module::findCentroid, - "vector = findCentroid(shape,direction): finds geometric centroid of shape looking in direction." + add_varargs_method("findCentroid", &Module::findCentroid, + "vector = findCentroid(shape, direction): finds geometric centroid of shape looking in direction." ); - add_varargs_method("makeExtentDim",&Module::makeExtentDim, + add_varargs_method("makeExtentDim", &Module::makeExtentDim, "makeExtentDim(DrawViewPart, [edges], direction) -- draw horizontal or vertical extent dimension for edges (or all of DrawViewPart if edge list is empty. direction: 0 - Horizontal, 1 - Vertical." ); - add_varargs_method("makeDistanceDim",&Module::makeDistanceDim, + add_varargs_method("makeDistanceDim", &Module::makeDistanceDim, "makeDistanceDim(DrawViewPart, dimType, fromPoint, toPoint) -- draw a Length dimension between fromPoint to toPoint. FromPoint and toPoint are unscaled 2d View points. dimType is one of ['Distance', 'DistanceX', 'DistanceY'." ); - add_varargs_method("makeDistanceDim3d",&Module::makeDistanceDim3d, + add_varargs_method("makeDistanceDim3d", &Module::makeDistanceDim3d, "makeDistanceDim(DrawViewPart, dimType, 3dFromPoint, 3dToPoint) -- draw a Length dimension between fromPoint to toPoint. FromPoint and toPoint are unscaled 3d model points. dimType is one of ['Distance', 'DistanceX', 'DistanceY'." ); - add_varargs_method("makeGeomHatch",&Module::makeGeomHatch, + add_varargs_method("makeGeomHatch", &Module::makeGeomHatch, "makeGeomHatch(face, [patScale], [patName], [patFile]) -- draw a geom hatch on a given face, using optionally the given scale (default 1) and a given pattern name (ex. Diamond) and .pat file (the default pattern name and/or .pat files set in preferences are used if none are given). Returns a Part compound shape." ); - add_varargs_method("project",&Module::project, - "[visiblyG0,visiblyG1,hiddenG0,hiddenG1] = project(TopoShape[,App.Vector Direction, string type])\n" + add_varargs_method("project", &Module::project, + "[visiblyG0, visiblyG1, hiddenG0, hiddenG1] = project(TopoShape[, App.Vector Direction, string type])\n" " -- Project a shape and return the visible/invisible parts of it." ); - add_varargs_method("projectEx",&Module::projectEx, - "[V,V1,VN,VO,VI,H,H1,HN,HO,HI] = projectEx(TopoShape[,App.Vector Direction, string type])\n" + add_varargs_method("projectEx", &Module::projectEx, + "[V, V1, VN, VO, VI, H,H1, HN, HO, HI] = projectEx(TopoShape[, App.Vector Direction, string type])\n" " -- Project a shape and return the all parts of it." ); - add_keyword_method("projectToSVG",&Module::projectToSVG, + add_keyword_method("projectToSVG", &Module::projectToSVG, "string = projectToSVG(TopoShape[, App.Vector direction, string type, float tolerance, dict vStyle, dict v0Style, dict v1Style, dict hStyle, dict h0Style, dict h1Style])\n" " -- Project a shape and return the SVG representation as string." ); - add_varargs_method("projectToDXF",&Module::projectToDXF, - "string = projectToDXF(TopoShape[,App.Vector Direction, string type])\n" + add_varargs_method("projectToDXF", &Module::projectToDXF, + "string = projectToDXF(TopoShape[, App.Vector Direction, string type])\n" " -- Project a shape and return the DXF representation as string." ); - add_varargs_method("removeSvgTags",&Module::removeSvgTags, + add_varargs_method("removeSvgTags", &Module::removeSvgTags, "string = removeSvgTags(string) -- Removes the opening and closing svg tags\n" "and other metatags from a svg code, making it embeddable" ); @@ -229,10 +229,10 @@ private: Py::Object edgeWalker(const Py::Tuple& args) { - PyObject *pcObj; + PyObject *pcObj = nullptr; PyObject *inclBig = Py_True; if (!PyArg_ParseTuple(args.ptr(), "O!|O", &(PyList_Type), &pcObj, &inclBig)) { - throw Py::TypeError("expected (listofedges,boolean"); + throw Py::TypeError("expected (listofedges, boolean"); } std::vector edgeList; @@ -240,10 +240,10 @@ private: Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapeEdgePy::Type))) { - const TopoDS_Shape& sh = static_cast((*it).ptr())-> + const TopoDS_Shape& shape = static_cast((*it).ptr())-> getTopoShapePtr()->getShape(); - const TopoDS_Edge e = TopoDS::Edge(sh); - edgeList.push_back(e); + const TopoDS_Edge edge = TopoDS::Edge(shape); + edgeList.push_back(edge); } } } @@ -257,22 +257,20 @@ private: return Py::None(); } - bool biggie; + bool biggie = false; if (inclBig == Py_True) { biggie = true; - } else { - biggie = false; } Py::List result; try { - EdgeWalker ew; - ew.loadEdges(edgeList); - bool success = ew.perform(); + EdgeWalker eWalker; + eWalker.loadEdges(edgeList); + bool success = eWalker.perform(); if (success) { - std::vector rw = ew.getResultNoDups(); - std::vector sortedWires = ew.sortStrip(rw,biggie); //false==>do not include biggest wires + std::vector rWires = eWalker.getResultNoDups(); + std::vector sortedWires = eWalker.sortStrip(rWires, biggie); //false==>do not include biggest wires for (auto& w:sortedWires) { PyObject* wire = new TopoShapeWirePy(new TopoShape(w)); result.append(Py::asObject(wire)); @@ -291,7 +289,7 @@ private: Py::Object findOuterWire(const Py::Tuple& args) { - PyObject *pcObj; + PyObject *pcObj = nullptr; if (!PyArg_ParseTuple(args.ptr(), "O!", &(PyList_Type), &pcObj)) { throw Py::TypeError("expected (listofedges)"); } @@ -302,10 +300,10 @@ private: Py::Sequence list(pcObj); for (Py::Sequence::iterator it = list.begin(); it != list.end(); ++it) { if (PyObject_TypeCheck((*it).ptr(), &(Part::TopoShapeEdgePy::Type))) { - const TopoDS_Shape& sh = static_cast((*it).ptr())-> + const TopoDS_Shape& shape = static_cast((*it).ptr())-> getTopoShapePtr()->getShape(); - const TopoDS_Edge e = TopoDS::Edge(sh); - edgeList.push_back(e); + const TopoDS_Edge edge = TopoDS::Edge(shape); + edgeList.push_back(edge); } } } @@ -322,12 +320,12 @@ private: PyObject* outerWire = nullptr; bool success = false; try { - EdgeWalker ew; - ew.loadEdges(edgeList); - success = ew.perform(); + EdgeWalker eWalker; + eWalker.loadEdges(edgeList); + success = eWalker.perform(); if (success) { - std::vector rw = ew.getResultNoDups(); - std::vector sortedWires = ew.sortStrip(rw,true); + std::vector rWires = eWalker.getResultNoDups(); + std::vector sortedWires = eWalker.sortStrip(rWires, true); outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin())); } else { Base::Console().Warning("findOuterWire: input is not planar graph. Wire detection not done\n"); @@ -345,13 +343,13 @@ private: Py::Object findShapeOutline(const Py::Tuple& args) { - PyObject *pcObjShape; - double scale; - PyObject *pcObjDir; + PyObject *pcObjShape(nullptr); + double scale(1.0); + PyObject *pcObjDir(nullptr); if (!PyArg_ParseTuple(args.ptr(), "OdO", &pcObjShape, &scale, &pcObjDir)) { - throw Py::TypeError("expected (shape,scale,direction"); + throw Py::TypeError("expected (shape, scale, direction"); } if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) { @@ -372,7 +370,7 @@ private: Base::Vector3d dir = static_cast(pcObjDir)->value(); std::vector edgeList; try { - edgeList = DrawProjectSplit::getEdgesForWalker(shape,scale,dir); + edgeList = DrawProjectSplit::getEdgesForWalker(shape, scale, dir); } catch (Standard_Failure& e) { @@ -387,11 +385,11 @@ private: PyObject* outerWire = nullptr; bool success = false; try { - EdgeWalker ew; - ew.loadEdges(edgeList); - if(ew.perform()) { - std::vector rw = ew.getResultNoDups(); - std::vector sortedWires = ew.sortStrip(rw,true); + EdgeWalker eWalker; + eWalker.loadEdges(edgeList); + if(eWalker.perform()) { + std::vector rWires = eWalker.getResultNoDups(); + std::vector sortedWires = eWalker.sortStrip(rWires, true); if(!sortedWires.empty()) { outerWire = new TopoShapeWirePy(new TopoShape(*sortedWires.begin())); success = true; @@ -412,7 +410,7 @@ private: Py::Object viewPartAsDxf(const Py::Tuple& args) { - PyObject *viewObj; + PyObject *viewObj(nullptr); if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) { throw Py::TypeError("expected (DrawViewPart)"); } @@ -427,32 +425,32 @@ private: if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) { obj = static_cast(viewObj)->getDocumentObjectPtr(); dvp = static_cast(obj); - TechDraw::GeometryObject* go = dvp->getGeometryObject(); - TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard()); - ss << dxfOut.exportEdges(s); - s = TechDraw::mirrorShape(go->getVisOutline()); - ss << dxfOut.exportEdges(s); + TechDraw::GeometryObject* gObj = dvp->getGeometryObject(); + TopoDS_Shape shape = TechDraw::mirrorShape(gObj->getVisHard()); + ss << dxfOut.exportEdges(shape); + shape = TechDraw::mirrorShape(gObj->getVisOutline()); + ss << dxfOut.exportEdges(shape); if (dvp->SmoothVisible.getValue()) { - s = TechDraw::mirrorShape(go->getVisSmooth()); - ss << dxfOut.exportEdges(s); + shape = TechDraw::mirrorShape(gObj->getVisSmooth()); + ss << dxfOut.exportEdges(shape); } if (dvp->SeamVisible.getValue()) { - s = TechDraw::mirrorShape(go->getVisSeam()); - ss << dxfOut.exportEdges(s); + shape = TechDraw::mirrorShape(gObj->getVisSeam()); + ss << dxfOut.exportEdges(shape); } if (dvp->HardHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidHard()); - ss << dxfOut.exportEdges(s); - s = TechDraw::mirrorShape(go->getHidOutline()); - ss << dxfOut.exportEdges(s); + shape = TechDraw::mirrorShape(gObj->getHidHard()); + ss << dxfOut.exportEdges(shape); + shape = TechDraw::mirrorShape(gObj->getHidOutline()); + ss << dxfOut.exportEdges(shape); } if (dvp->SmoothHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidSmooth()); - ss << dxfOut.exportEdges(s); + shape = TechDraw::mirrorShape(gObj->getHidSmooth()); + ss << dxfOut.exportEdges(shape); } if (dvp->SeamHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidSeam()); - ss << dxfOut.exportEdges(s); + shape = TechDraw::mirrorShape(gObj->getHidSeam()); + ss << dxfOut.exportEdges(shape); } // ss now contains all edges as Dxf dxfReturn = Py::String(ss.str()); @@ -468,7 +466,7 @@ private: Py::Object viewPartAsSvg(const Py::Tuple& args) { - PyObject *viewObj; + PyObject *viewObj(nullptr); if (!PyArg_ParseTuple(args.ptr(), "O", &viewObj)) { throw Py::TypeError("expected (DrawViewPart)"); } @@ -485,24 +483,24 @@ private: if (PyObject_TypeCheck(viewObj, &(TechDraw::DrawViewPartPy::Type))) { obj = static_cast(viewObj)->getDocumentObjectPtr(); dvp = static_cast(obj); - TechDraw::GeometryObject* go = dvp->getGeometryObject(); + TechDraw::GeometryObject* gObj = dvp->getGeometryObject(); //visible group begin "" ss << grpHead1; // double thick = dvp->LineWidth.getValue(); double thick = DrawUtil::getDefaultLineWeight("Thick"); ss << thick; ss << grpHead2; - TopoDS_Shape s = go->getVisHard(); - ss << svgOut.exportEdges(s); - s = (go->getVisOutline()); - ss << svgOut.exportEdges(s); + TopoDS_Shape shape = gObj->getVisHard(); + ss << svgOut.exportEdges(shape); + shape = gObj->getVisOutline(); + ss << svgOut.exportEdges(shape); if (dvp->SmoothVisible.getValue()) { - s = go->getVisSmooth(); - ss << svgOut.exportEdges(s); + shape = gObj->getVisSmooth(); + ss << svgOut.exportEdges(shape); } if (dvp->SeamVisible.getValue()) { - s = go->getVisSeam(); - ss << svgOut.exportEdges(s); + shape = gObj->getVisSeam(); + ss << svgOut.exportEdges(shape); } //visible group end "" ss << grpTail; @@ -517,18 +515,18 @@ private: ss << thick; ss << grpHead2; if (dvp->HardHidden.getValue()) { - s = go->getHidHard(); - ss << svgOut.exportEdges(s); - s = go->getHidOutline(); - ss << svgOut.exportEdges(s); + shape = gObj->getHidHard(); + ss << svgOut.exportEdges(shape); + shape = gObj->getHidOutline(); + ss << svgOut.exportEdges(shape); } if (dvp->SmoothHidden.getValue()) { - s = go->getHidSmooth(); - ss << svgOut.exportEdges(s); + shape = gObj->getHidSmooth(); + ss << svgOut.exportEdges(shape); } if (dvp->SeamHidden.getValue()) { - s = go->getHidSeam(); - ss << svgOut.exportEdges(s); + shape = gObj->getHidSeam(); + ss << svgOut.exportEdges(shape); } ss << grpTail; //hidden group end @@ -549,8 +547,8 @@ private: { if(!dvp->hasGeometry()) return; - TechDraw::GeometryObject* go = dvp->getGeometryObject(); - TopoDS_Shape s = TechDraw::mirrorShape(go->getVisHard()); + TechDraw::GeometryObject* gObj = dvp->getGeometryObject(); + TopoDS_Shape shape = TechDraw::mirrorShape(gObj->getVisHard()); double offX = 0.0; double offY = 0.0; if (dvp->isDerivedFrom(TechDraw::DrawProjGroupItem::getClassTypeId())) { @@ -561,56 +559,54 @@ private: offY = dpg->Y.getValue(); } } - double dvpX,dvpY; + double dvpX(0.0); + double dvpY(0.0); if (alignPage) { dvpX = dvp->X.getValue() + offX; dvpY = dvp->Y.getValue() + offY; - } else { - dvpX = 0.0; - dvpY = 0.0; } gp_Trsf xLate; - xLate.SetTranslation(gp_Vec(dvpX,dvpY,0.0)); - BRepBuilderAPI_Transform mkTrf(s, xLate); - s = mkTrf.Shape(); - writer.exportShape(s); - s = TechDraw::mirrorShape(go->getVisOutline()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + xLate.SetTranslation(gp_Vec(dvpX, dvpY, 0.0)); + BRepBuilderAPI_Transform mkTrf(shape, xLate); + shape = mkTrf.Shape(); + writer.exportShape(shape); + shape = TechDraw::mirrorShape(gObj->getVisOutline()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); if (dvp->SmoothVisible.getValue()) { - s = TechDraw::mirrorShape(go->getVisSmooth()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(gObj->getVisSmooth()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } if (dvp->SeamVisible.getValue()) { - s = TechDraw::mirrorShape(go->getVisSeam()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(gObj->getVisSeam()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } if (dvp->HardHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidHard()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); - s = TechDraw::mirrorShape(go->getHidOutline()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(gObj->getHidHard()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); + shape = TechDraw::mirrorShape(gObj->getHidOutline()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } if (dvp->SmoothHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidSmooth()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(gObj->getHidSmooth()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } if (dvp->SeamHidden.getValue()) { - s = TechDraw::mirrorShape(go->getHidSeam()); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(gObj->getHidSeam()); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } //add the cosmetic edges also std::vector geoms = dvp->getEdgeGeometry(); @@ -621,30 +617,28 @@ private: } } if (!cosmeticEdges.empty()) { - s = TechDraw::mirrorShape(DrawUtil::vectorToCompound(cosmeticEdges)); - mkTrf.Perform(s); - s = mkTrf.Shape(); - writer.exportShape(s); + shape = TechDraw::mirrorShape(DrawUtil::vectorToCompound(cosmeticEdges)); + mkTrf.Perform(shape); + shape = mkTrf.Shape(); + writer.exportShape(shape); } } Py::Object writeDXFView(const Py::Tuple& args) { - PyObject *viewObj; - char* name; + PyObject *viewObj(nullptr); + char* name(nullptr); PyObject *alignObj = Py_True; - if (!PyArg_ParseTuple(args.ptr(), "Oet|O", &viewObj, "utf-8",&name,&alignObj)) { - throw Py::TypeError("expected (view,path"); + if (!PyArg_ParseTuple(args.ptr(), "Oet|O", &viewObj, "utf-8", &name, &alignObj)) { + throw Py::TypeError("expected (view, path"); } std::string filePath = std::string(name); std::string layerName = "none"; PyMem_Free(name); - bool align; + bool align = false; if (alignObj == Py_True) { align = true; - } else { - align = false; } try { @@ -658,7 +652,7 @@ private: layerName = dvp->getNameInDocument(); writer.setLayerName(layerName); - write1ViewDxf(writer,dvp,align); + write1ViewDxf(writer, dvp, align); } writer.endRun(); } @@ -671,10 +665,10 @@ private: Py::Object writeDXFPage(const Py::Tuple& args) { - PyObject *pageObj; - char* name; - if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) { - throw Py::TypeError("expected (page,path"); + PyObject *pageObj(nullptr); + char* name(nullptr); + if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8", &name)) { + throw Py::TypeError("expected (page, path"); } std::string filePath = std::string(name); @@ -685,30 +679,30 @@ private: ImpExpDxfWrite writer(filePath); writer.init(); App::DocumentObject* obj = nullptr; - TechDraw::DrawPage* dp = nullptr; + TechDraw::DrawPage* dPage = nullptr; if (PyObject_TypeCheck(pageObj, &(TechDraw::DrawPagePy::Type))) { obj = static_cast(pageObj)->getDocumentObjectPtr(); - dp = static_cast(obj); - auto views = dp->getAllViews(); - for (auto& v: views) { - if (v->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { - TechDraw::DrawViewPart* dvp = static_cast(v); + dPage = static_cast(obj); + auto views = dPage->getAllViews(); + for (auto& view : views) { + if (view->isDerivedFrom(TechDraw::DrawViewPart::getClassTypeId())) { + TechDraw::DrawViewPart* dvp = static_cast(view); layerName = dvp->getNameInDocument(); writer.setLayerName(layerName); - write1ViewDxf(writer,dvp,true); - } else if (v->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) { - TechDraw::DrawViewAnnotation* dva = static_cast(v); + write1ViewDxf(writer, dvp, true); + + } else if (view->isDerivedFrom(TechDraw::DrawViewAnnotation::getClassTypeId())) { + TechDraw::DrawViewAnnotation* dva = static_cast(view); layerName = dva->getNameInDocument(); writer.setLayerName(layerName); double height = dva->TextSize.getValue(); //mm int just = 1; //centered - double x = dva->X.getValue(); - double y = dva->Y.getValue(); - Base::Vector3d loc(x,y,0.0); + Base::Vector3d loc(dva->X.getValue(), dva->Y.getValue(), 0.0); auto lines = dva->Text.getValues(); - writer.exportText(lines[0].c_str(),loc,loc, height,just); - } else if (v->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) { - DrawViewDimension* dvd = static_cast(v); + writer.exportText(lines[0].c_str(), loc, loc, height, just); + + } else if (view->isDerivedFrom(TechDraw::DrawViewDimension::getClassTypeId())) { + DrawViewDimension* dvd = static_cast(view); TechDraw::DrawViewPart* dvp = dvd->getViewPart(); if (!dvp) { continue; @@ -726,7 +720,7 @@ private: } double parentX = dvp->X.getValue() + grandParentX; double parentY = dvp->Y.getValue() + grandParentY; - Base::Vector3d parentPos(parentX,parentY,0.0); + Base::Vector3d parentPos(parentX, parentY, 0.0); std::string sDimText; //this is the same code as in QGIViewDimension::updateDim if (dvd->isMultiValueSchema()) { @@ -743,16 +737,16 @@ private: dvd->Type.isValue("DistanceX") || dvd->Type.isValue("DistanceY") ) { Base::Vector3d textLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0); - Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY,0.0); + Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0); pointPair pts = dvd->getLinearPoints(); Base::Vector3d dimLine = pts.first - pts.second; - Base::Vector3d norm(-dimLine.y,dimLine.x,0.0); + Base::Vector3d norm(-dimLine.y, dimLine.x, 0.0); norm.Normalize(); lineLocn = lineLocn + (norm * gap); - Base::Vector3d extLine1Start = Base::Vector3d(pts.first.x,-pts.first.y,0.0) + - Base::Vector3d(parentX,parentY,0.0); + Base::Vector3d extLine1Start = Base::Vector3d(pts.first.x, -pts.first.y, 0.0) + + Base::Vector3d(parentX, parentY, 0.0); Base::Vector3d extLine2Start = Base::Vector3d(pts.second.x, -pts.second.y, 0.0) + - Base::Vector3d(parentX,parentY,0.0); + Base::Vector3d(parentX, parentY, 0.0); if (dvd->Type.isValue("DistanceX") ) { type = 1; } else if (dvd->Type.isValue("DistanceY") ) { @@ -761,7 +755,7 @@ private: writer.exportLinearDim(textLocn, lineLocn, extLine1Start, extLine2Start, dimText, type); } else if (dvd->Type.isValue("Angle")) { Base::Vector3d textLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0); - Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY,0.0); + Base::Vector3d lineLocn(dvd->X.getValue() + parentX, dvd->Y.getValue() + parentY, 0.0); anglePoints pts = dvd->getAnglePoints(); Base::Vector3d end1 = pts.ends.first; end1.y = -end1.y; @@ -773,7 +767,7 @@ private: apex = apex + parentPos; Base::Vector3d dimLine = end2 - end1; - Base::Vector3d norm(-dimLine.y,dimLine.x,0.0); + Base::Vector3d norm(-dimLine.y, dimLine.x, 0.0); norm.Normalize(); lineLocn = lineLocn + (norm * gap); end1 = end1 + parentPos; @@ -815,11 +809,11 @@ private: Py::Object findCentroid(const Py::Tuple& args) { - PyObject *pcObjShape; - PyObject *pcObjDir; + PyObject *pcObjShape(nullptr); + PyObject *pcObjDir(nullptr); if (!PyArg_ParseTuple(args.ptr(), "OO", &pcObjShape, &pcObjDir)) { - throw Py::TypeError("expected (shape,direction"); + throw Py::TypeError("expected (shape, direction"); } if (!PyObject_TypeCheck(pcObjShape, &(TopoShapePy::Type))) { @@ -838,16 +832,16 @@ private: const TopoDS_Shape& shape = pShape->getTopoShapePtr()->getShape(); Base::Vector3d dir = static_cast(pcObjDir)->value(); - Base::Vector3d c = TechDraw::findCentroidVec(shape,dir); + Base::Vector3d centroid = TechDraw::findCentroidVec(shape, dir); PyObject* result = nullptr; - result = new Base::VectorPy(new Base::Vector3d(c)); + result = new Base::VectorPy(new Base::Vector3d(centroid)); return Py::asObject(result); } Py::Object makeExtentDim(const Py::Tuple& args) { - PyObject* pDvp; - PyObject* pEdgeList; + PyObject* pDvp(nullptr); + PyObject* pEdgeList(nullptr); int direction = 0; //Horizontal TechDraw::DrawViewPart* dvp = nullptr; @@ -882,12 +876,12 @@ private: Py::Object makeDistanceDim(const Py::Tuple& args) { - //points come in unscaled,but makeDistDim unscales them so we need to prescale here. + //points come in unscaled, but makeDistDim unscales them so we need to prescale here. //makeDistDim was built for extent dims which work from scaled geometry - PyObject* pDvp; - PyObject* pDimType; - PyObject* pFrom; - PyObject* pTo; + PyObject* pDvp(nullptr); + PyObject* pDimType(nullptr); + PyObject* pFrom(nullptr); + PyObject* pTo(nullptr); TechDraw::DrawViewPart* dvp = nullptr; std::string dimType; Base::Vector3d from; @@ -970,7 +964,7 @@ private: Py::Object makeGeomHatch(const Py::Tuple& args) { - PyObject* pFace; + PyObject* pFace(nullptr); double scale = 1.0; char* pPatName = ""; char* pPatFile = ""; @@ -987,8 +981,8 @@ private: PyMem_Free(pPatFile); if (PyObject_TypeCheck(pFace, &(TopoShapeFacePy::Type))) { - const TopoDS_Shape& sh = static_cast(pFace)->getTopoShapePtr()->getShape(); - face = TopoDS::Face(sh); + const TopoDS_Shape& shape = static_cast(pFace)->getTopoShapePtr()->getShape(); + face = TopoDS::Face(shape); } else { throw Py::TypeError("first argument must be a Part.Face instance"); @@ -1001,15 +995,15 @@ private: } Base::FileInfo fi(patFile); if (!fi.isReadable()) { - Base::Console().Error(".pat File: %s is not readable\n",patFile.c_str()); + Base::Console().Error(".pat File: %s is not readable\n", patFile.c_str()); return Py::None(); } std::vector specs = TechDraw::DrawGeomHatch::getDecodedSpecsFromFile(patFile, patName); std::vector lineSets; - for (auto& hl: specs) { - TechDraw::LineSet ls; - ls.setPATLineSpec(hl); - lineSets.push_back(ls); + for (auto& hLine : specs) { + TechDraw::LineSet lSet; + lSet.setPATLineSpec(hLine); + lineSets.push_back(lSet); } std::vector lsresult = TechDraw::DrawGeomHatch::getTrimmedLines(source, lineSets, face, scale); if (!lsresult.empty()) { @@ -1055,8 +1049,8 @@ private: Py::Object project(const Py::Tuple& args) { - PyObject *pcObjShape; - PyObject *pcObjDir=nullptr; + PyObject *pcObjShape(nullptr); + PyObject *pcObjDir(nullptr); if (!PyArg_ParseTuple(args.ptr(), "O!|O!", &(Part::TopoShapePy::Type), &pcObjShape, @@ -1064,11 +1058,11 @@ private: throw Py::Exception(); Part::TopoShapePy* pShape = static_cast(pcObjShape); - Base::Vector3d Vector(0,0,1); + Base::Vector3d Vector(0, 0,1); if (pcObjDir) Vector = *static_cast(pcObjDir)->getVectorPtr(); - ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector); + ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector); Py::List list; list.append(Py::Object(new Part::TopoShapePy(new Part::TopoShape(Alg.V)) , true)); @@ -1080,8 +1074,8 @@ private: } Py::Object projectEx(const Py::Tuple& args) { - PyObject *pcObjShape; - PyObject *pcObjDir=nullptr; + PyObject *pcObjShape(nullptr); + PyObject *pcObjDir(nullptr); if (!PyArg_ParseTuple(args.ptr(), "O!|O!", &(TopoShapePy::Type), &pcObjShape, @@ -1089,11 +1083,11 @@ private: throw Py::Exception(); TopoShapePy* pShape = static_cast(pcObjShape); - Base::Vector3d Vector(0,0,1); + Base::Vector3d Vector(0, 0,1); if (pcObjDir) Vector = *static_cast(pcObjDir)->getVectorPtr(); - ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector); + ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector); Py::List list; list.append(Py::Object(new TopoShapePy(new TopoShape(Alg.V)) , true)); @@ -1130,26 +1124,26 @@ private: ProjectionAlgos::XmlAttributes h0Style; PyObject* h1StylePy = nullptr; ProjectionAlgos::XmlAttributes h1Style; - + // Get the arguments if (!PyArg_ParseTupleAndKeywords( - args.ptr(), keys.ptr(), - "O!|O!sfOOOOOO", + args.ptr(), keys.ptr(), + "O!|O!sfOOOOOO", argNames, &(TopoShapePy::Type), &pcObjShape, - &(Base::VectorPy::Type), &pcObjDir, - &extractionTypePy, &tol, - &vStylePy, &v0StylePy, &v1StylePy, + &(Base::VectorPy::Type), &pcObjDir, + &extractionTypePy, &tol, + &vStylePy, &v0StylePy, &v1StylePy, &hStylePy, &h0StylePy, &h1StylePy)) - + throw Py::Exception(); // Convert all arguments into the right format TopoShapePy* pShape = static_cast(pcObjShape); - Base::Vector3d directionVector(0,0,1); + Base::Vector3d directionVector(0, 0,1); if (pcObjDir) directionVector = static_cast(pcObjDir)->value(); @@ -1168,20 +1162,20 @@ private: copy(Py::Dict(h0StylePy), inserter(h0Style, h0Style.begin())); if (h1StylePy) copy(Py::Dict(h1StylePy), inserter(h1Style, h1Style.begin())); - + // Execute the SVG generation - ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), + ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), directionVector); - Py::String result(Alg.getSVG(extractionType, tol, - vStyle, v0Style, v1Style, + Py::String result(Alg.getSVG(extractionType, tol, + vStyle, v0Style, v1Style, hStyle, h0Style, h1Style)); return result; } Py::Object projectToDXF(const Py::Tuple& args) { - PyObject *pcObjShape; + PyObject *pcObjShape(nullptr); PyObject *pcObjDir=nullptr; const char *type=nullptr; float scale=1.0f; @@ -1193,10 +1187,10 @@ private: throw Py::Exception(); TopoShapePy* pShape = static_cast(pcObjShape); - Base::Vector3d Vector(0,0,1); + Base::Vector3d Vector(0, 0,1); if (pcObjDir) Vector = static_cast(pcObjDir)->value(); - ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(),Vector); + ProjectionAlgos Alg(pShape->getTopoShapePtr()->getShape(), Vector); bool hidden = false; if (type && std::string(type) == "ShowHiddenLines") @@ -1208,7 +1202,7 @@ private: Py::Object removeSvgTags(const Py::Tuple& args) { const char* svgcode; - if (!PyArg_ParseTuple(args.ptr(), "s",&svgcode)) + if (!PyArg_ParseTuple(args.ptr(), "s", &svgcode)) throw Py::Exception(); std::string svg(svgcode); diff --git a/src/Mod/TechDraw/App/ArrowPropEnum.h b/src/Mod/TechDraw/App/ArrowPropEnum.h index 49a2540270..8100231ff0 100644 --- a/src/Mod/TechDraw/App/ArrowPropEnum.h +++ b/src/Mod/TechDraw/App/ArrowPropEnum.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _ARROWENUMS_H_ -#define _ARROWENUMS_H_ +#ifndef ARROWENUMS_H_ +#define ARROWENUMS_H_ #include diff --git a/src/Mod/TechDraw/App/CenterLinePyImp.cpp b/src/Mod/TechDraw/App/CenterLinePyImp.cpp index f7f20bfa7a..5fa33bcd38 100644 --- a/src/Mod/TechDraw/App/CenterLinePyImp.cpp +++ b/src/Mod/TechDraw/App/CenterLinePyImp.cpp @@ -1,422 +1,422 @@ -/*************************************************************************** - * Copyright (c) 2008 Werner Mayer * - * * - * This file is part of the FreeCAD CAx development system. * - * * - * This library is free software; you can redistribute it and/or * - * modify it under the terms of the GNU Library General Public * - * License as published by the Free Software Foundation; either * - * version 2 of the License, or (at your option) any later version. * - * * - * This library is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU Library General Public License for more details. * - * * - * You should have received a copy of the GNU Library General Public * - * License along with this library; see the file COPYING.LIB. If not, * - * write to the Free Software Foundation, Inc., 59 Temple Place, * - * Suite 330, Boston, MA 02111-1307, USA * - * * - ***************************************************************************/ - - -#include "PreCompiled.h" -#ifndef _PreComp_ - -# include -#endif - -#include "DrawUtil.h" -#include "Cosmetic.h" -#include "CenterLinePy.h" -#include "CenterLinePy.cpp" - -using namespace TechDraw; - -// returns a string which represents the object e.g. when printed in python -std::string CenterLinePy::representation() const -{ - std::stringstream ss; - ss << " at " << std::hex << this; - return ss.str(); -} - -PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper -{ - // never create such objects with the constructor - PyErr_SetString(PyExc_RuntimeError, - "You cannot create an instance of the abstract class 'CenterLine'."); - return nullptr; -} - -// constructor method -int CenterLinePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) -{ - return 0; -} - -PyObject* CenterLinePy::clone(PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) - return nullptr; - - TechDraw::CenterLine* geom = this->getCenterLinePtr(); - PyTypeObject* type = this->GetType(); - PyObject* cpy = nullptr; - // let the type object decide - if (type->tp_new) - cpy = type->tp_new(type, this, nullptr); - if (!cpy) { - PyErr_SetString(PyExc_TypeError, "failed to create clone of CenterLine"); - return nullptr; - } - - TechDraw::CenterLinePy* geompy = static_cast(cpy); - // the PyMake function must have created the corresponding instance of the 'CenterLine' subclass - // so delete it now to avoid a memory leak - if (geompy->_pcTwinPointer) { - TechDraw::CenterLine* clone = static_cast(geompy->_pcTwinPointer); - delete clone; - } - geompy->_pcTwinPointer = geom->clone(); - return cpy; -} - -PyObject* CenterLinePy::copy(PyObject *args) -{ - if (!PyArg_ParseTuple(args, "")) - return nullptr; - - TechDraw::CenterLine* geom = this->getCenterLinePtr(); - PyTypeObject* type = this->GetType(); - PyObject* cpy = nullptr; - // let the type object decide - if (type->tp_new) - cpy = type->tp_new(type, this, nullptr); - if (!cpy) { - PyErr_SetString(PyExc_TypeError, "failed to create copy of CenterLine"); - return nullptr; - } - - TechDraw::CenterLinePy* geompy = static_cast(cpy); - // the PyMake function must have created the corresponding instance of the 'CenterLine' subclass - // so delete it now to avoid a memory leak - if (geompy->_pcTwinPointer) { - TechDraw::CenterLine* copy = static_cast(geompy->_pcTwinPointer); - delete copy; - } - geompy->_pcTwinPointer = geom->copy(); - return cpy; -} - -Py::Object CenterLinePy::getFormat() const -{ - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - - PyObject* pStyle = PyLong_FromLong((long) cl->m_format.m_style); - PyObject* pWeight = PyFloat_FromDouble(cl->m_format.m_weight); - PyObject* pColor = DrawUtil::colorToPyTuple(cl->m_format.m_color); - PyObject* pVisible = PyBool_FromLong((long) cl->m_format.m_visible); - - PyObject* result = PyTuple_New(4); - - PyTuple_SET_ITEM(result, 0, pStyle); - PyTuple_SET_ITEM(result, 1, pWeight); - PyTuple_SET_ITEM(result, 2, pColor); - PyTuple_SET_ITEM(result, 3, pVisible); - - return Py::asObject(result); -} - -void CenterLinePy::setFormat(Py::Object arg) -{ - PyObject* pTuple = arg.ptr(); - int style = 1; - double weight = 0.50; - double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; - App::Color c(red, blue, green, alpha); - bool visible = 1; - - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - if (PyTuple_Check(pTuple)) { - int tSize = (int) PyTuple_Size(pTuple); - if (tSize > 3) { - PyObject* pStyle = PyTuple_GetItem(pTuple,0); - style = (int) PyLong_AsLong(pStyle); - PyObject* pWeight = PyTuple_GetItem(pTuple,1); - weight = PyFloat_AsDouble(pWeight); - PyObject* pColor = PyTuple_GetItem(pTuple,2); - c = DrawUtil::pyTupleToColor(pColor); - PyObject* pVisible = PyTuple_GetItem(pTuple,3); - visible = (bool) PyLong_AsLong(pVisible); - cl->m_format.m_style = style; - cl->m_format.m_weight = weight; - cl->m_format.m_color = c; - cl->m_format.m_visible = visible; - } - } else { - Base::Console().Error("CLPI::setFormat - not a tuple!\n"); - } -} - -Py::String CenterLinePy::getTag() const -{ - std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag()); - return Py::String(tmp); -} - - -Py::Long CenterLinePy::getType() const -{ - int tmp = getCenterLinePtr()->m_type; - return Py::Long(tmp); -} - -Py::Long CenterLinePy::getMode() const -{ - int tmp = getCenterLinePtr()->m_mode; - return Py::Long(tmp); -} - -void CenterLinePy::setMode(Py::Long arg) -{ - PyObject* p = arg.ptr(); - if (PyLong_Check(p)) { - long int temp = PyLong_AsLong(p); - getCenterLinePtr()->m_mode = (int) temp; - } else { - std::string error = std::string("type must be 'Integer', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Float CenterLinePy::getHorizShift() const -{ - double shift = getCenterLinePtr()->getHShift(); - return Py::asObject(PyFloat_FromDouble(shift)); -} - -void CenterLinePy::setHorizShift(Py::Float arg) -{ - PyObject* p = arg.ptr(); - if (PyFloat_Check(p)) { - double hshift = PyFloat_AsDouble(p); - double vshift = getCenterLinePtr()->getVShift(); - getCenterLinePtr()->setShifts(hshift, vshift); - } else { - std::string error = std::string("type must be 'Float', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Float CenterLinePy::getVertShift() const -{ - double shift = getCenterLinePtr()->getVShift(); - return Py::asObject(PyFloat_FromDouble(shift)); -} - -void CenterLinePy::setVertShift(Py::Float arg) -{ - PyObject* p = arg.ptr(); - if (PyFloat_Check(p)) { - double vshift = PyFloat_AsDouble(p); - double hshift = getCenterLinePtr()->getHShift(); - getCenterLinePtr()->setShifts(hshift, vshift); - } else { - std::string error = std::string("type must be 'Float', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Float CenterLinePy::getRotation() const -{ - double rot = getCenterLinePtr()->getRotate(); - return Py::asObject(PyFloat_FromDouble(rot)); -} - -void CenterLinePy::setRotation(Py::Float arg) -{ - PyObject* p = arg.ptr(); - if (PyFloat_Check(p)) { - double rot = PyFloat_AsDouble(p); - getCenterLinePtr()->setRotate(rot); - } else { - std::string error = std::string("type must be 'Float', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Float CenterLinePy::getExtension() const -{ - double rot = getCenterLinePtr()->getExtend(); - return Py::asObject(PyFloat_FromDouble(rot)); -} - -void CenterLinePy::setExtension(Py::Float arg) -{ - PyObject* p = arg.ptr(); - if (PyFloat_Check(p)) { - double ext = PyFloat_AsDouble(p); - getCenterLinePtr()->setExtend(ext); - } else { - std::string error = std::string("type must be 'Float', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Boolean CenterLinePy::getFlip() const -{ - bool flip = getCenterLinePtr()->getFlip(); - return Py::Boolean(flip); -} - -void CenterLinePy::setFlip(Py::Boolean arg) -{ - PyObject* p = arg.ptr(); - if (PyBool_Check(p)) { - if (p == Py_True) { - getCenterLinePtr()->setFlip(true); - } else { - getCenterLinePtr()->setFlip(false); - } - } else { - std::string error = std::string("type must be 'Boolean', not "); - error += p->ob_type->tp_name; - throw Py::TypeError(error); - } -} - -Py::Object CenterLinePy::getEdges() const -{ -// Base::Console().Message("CLP::getEdges()\n"); - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - - std::vector edges = cl->m_edges; - int size = edges.size(); - - Py::List result(size); - - for (auto& e: edges) { - result.append(Py::asObject(PyUnicode_FromString(e.c_str()))); - } - - return result; -} - -void CenterLinePy::setEdges(Py::Object arg) -{ -// Base::Console().Message("CLP::setEdges()\n"); - PyObject* pList = arg.ptr(); - - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - std::vector temp; - if (PyList_Check(pList)) { - int tSize = (int) PyList_Size(pList); - int i = 0; - for ( ; i < tSize; i++) { - PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); - if (PyUnicode_Check(item)) { - std::string s = PyUnicode_AsUTF8(item); //py3 only!!! - temp.push_back(s); - } - } - cl->m_edges = temp; - } else { - Base::Console().Error("CLPI::setEdges - input not a list!\n"); - } -} -Py::Object CenterLinePy::getFaces() const -{ -// Base::Console().Message("CLP::getFaces()\n"); - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - - std::vector faces = cl->m_faces; - int size = faces.size(); - - Py::List result(size); - - for (auto& f: faces) { - result.append(Py::asObject(PyUnicode_FromString(f.c_str()))); - } - - return result; -} - -void CenterLinePy::setFaces(Py::Object arg) -{ -// Base::Console().Message("CLP::setFaces()\n"); - PyObject* pList = arg.ptr(); - - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - std::vector temp; - if (PyList_Check(pList)) { - int tSize = (int) PyList_Size(pList); - int i = 0; - for ( ; i < tSize; i++) { - PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); - if (PyUnicode_Check(item)) { - std::string s = PyUnicode_AsUTF8(item); //py3 only!!! - temp.push_back(s); - } - } - cl->m_faces = temp; - } else { - Base::Console().Error("CLPI::setFaces - input not a list!\n"); - } -} - -Py::Object CenterLinePy::getPoints() const -{ -// Base::Console().Message("CLP::getPoints()\n"); - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - - std::vector points = cl->m_verts; - int size = points.size(); - - Py::List result(size); - - for (auto& p: points) { - result.append(Py::asObject(PyUnicode_FromString(p.c_str()))); - } - - return result; -} - -void CenterLinePy::setPoints(Py::Object arg) -{ -// Base::Console().Message("CLP::setPoints()\n"); - PyObject* pList = arg.ptr(); - - TechDraw::CenterLine* cl = this->getCenterLinePtr(); - std::vector temp; - if (PyList_Check(pList)) { - int tSize = (int) PyList_Size(pList); - int i = 0; - for ( ; i < tSize; i++) { - PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); - if (PyUnicode_Check(item)) { - std::string s = PyUnicode_AsUTF8(item); //py3 only!!! - temp.push_back(s); - } - } - cl->m_verts = temp; - } else { - Base::Console().Error("CLPI::setPoints - input not a list!\n"); - } -} - -PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const -{ - return nullptr; -} - -int CenterLinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) -{ - return 0; -} +/*************************************************************************** + * Copyright (c) 2008 Werner Mayer * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + + +#include "PreCompiled.h" +#ifndef _PreComp_ + +# include +#endif + +#include + +#include "DrawUtil.h" +#include "Cosmetic.h" +#include "CenterLinePy.h" + +using namespace TechDraw; + +// returns a string which represents the object e.g. when printed in python +std::string CenterLinePy::representation() const +{ + std::stringstream sStream; + sStream << " at " << std::hex << this; + return sStream.str(); +} + +PyObject *CenterLinePy::PyMake(struct _typeobject *, PyObject *, PyObject *) // Python wrapper +{ + // never create such objects with the constructor + PyErr_SetString(PyExc_RuntimeError, + "You cannot create an instance of the abstract class 'CenterLine'."); + return nullptr; +} + +// constructor method +int CenterLinePy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) +{ + return 0; +} + +PyObject* CenterLinePy::clone(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + TechDraw::CenterLine* geom = this->getCenterLinePtr(); + PyTypeObject* type = this->GetType(); + PyObject* cpy = nullptr; + // let the type object decide + if (type->tp_new) + cpy = type->tp_new(type, this, nullptr); + if (!cpy) { + PyErr_SetString(PyExc_TypeError, "failed to create clone of CenterLine"); + return nullptr; + } + + TechDraw::CenterLinePy* geompy = static_cast(cpy); + // the PyMake function must have created the corresponding instance of the 'CenterLine' subclass + // so delete it now to avoid a memory leak + if (geompy->_pcTwinPointer) { + TechDraw::CenterLine* clone = static_cast(geompy->_pcTwinPointer); + delete clone; + } + geompy->_pcTwinPointer = geom->clone(); + return cpy; +} + +PyObject* CenterLinePy::copy(PyObject *args) +{ + if (!PyArg_ParseTuple(args, "")) + return nullptr; + + TechDraw::CenterLine* geom = this->getCenterLinePtr(); + PyTypeObject* type = this->GetType(); + PyObject* cpy = nullptr; + // let the type object decide + if (type->tp_new) + cpy = type->tp_new(type, this, nullptr); + if (!cpy) { + PyErr_SetString(PyExc_TypeError, "failed to create copy of CenterLine"); + return nullptr; + } + + TechDraw::CenterLinePy* geompy = static_cast(cpy); + // the PyMake function must have created the corresponding instance of the 'CenterLine' subclass + // so delete it now to avoid a memory leak + if (geompy->_pcTwinPointer) { + TechDraw::CenterLine* copy = static_cast(geompy->_pcTwinPointer); + delete copy; + } + geompy->_pcTwinPointer = geom->copy(); + return cpy; +} + +Py::Object CenterLinePy::getFormat() const +{ + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + + PyObject* pStyle = PyLong_FromLong((long) cLine->m_format.m_style); + PyObject* pWeight = PyFloat_FromDouble(cLine->m_format.m_weight); + PyObject* pColor = DrawUtil::colorToPyTuple(cLine->m_format.m_color); + PyObject* pVisible = PyBool_FromLong((long) cLine->m_format.m_visible); + + PyObject* result = PyTuple_New(4); + + PyTuple_SET_ITEM(result, 0, pStyle); + PyTuple_SET_ITEM(result, 1, pWeight); + PyTuple_SET_ITEM(result, 2, pColor); + PyTuple_SET_ITEM(result, 3, pVisible); + + return Py::asObject(result); +} + +void CenterLinePy::setFormat(Py::Object arg) +{ + PyObject* pTuple = arg.ptr(); + int style = 1; + double weight = 0.50; + double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; + App::Color color(red, blue, green, alpha); + bool visible = 1; + + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + if (PyTuple_Check(pTuple)) { + int tSize = (int) PyTuple_Size(pTuple); + if (tSize > 3) { + PyObject* pStyle = PyTuple_GetItem(pTuple, 0); + style = (int) PyLong_AsLong(pStyle); + PyObject* pWeight = PyTuple_GetItem(pTuple, 1); + weight = PyFloat_AsDouble(pWeight); + PyObject* pColor = PyTuple_GetItem(pTuple, 2); + color = DrawUtil::pyTupleToColor(pColor); + PyObject* pVisible = PyTuple_GetItem(pTuple, 3); + visible = (bool) PyLong_AsLong(pVisible); + cLine->m_format.m_style = style; + cLine->m_format.m_weight = weight; + cLine->m_format.m_color = color; + cLine->m_format.m_visible = visible; + } + } else { + Base::Console().Error("CLPI::setFormat - not a tuple!\n"); + } +} + +Py::String CenterLinePy::getTag() const +{ + std::string tmp = boost::uuids::to_string(getCenterLinePtr()->getTag()); + return Py::String(tmp); +} + + +Py::Long CenterLinePy::getType() const +{ + int tmp = getCenterLinePtr()->m_type; + return Py::Long(tmp); +} + +Py::Long CenterLinePy::getMode() const +{ + int tmp = getCenterLinePtr()->m_mode; + return Py::Long(tmp); +} + +void CenterLinePy::setMode(Py::Long arg) +{ + PyObject* pObj = arg.ptr(); + if (PyLong_Check(pObj)) { + long int temp = PyLong_AsLong(pObj); + getCenterLinePtr()->m_mode = (int) temp; + } else { + std::string error = std::string("type must be 'Integer', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Float CenterLinePy::getHorizShift() const +{ + double shift = getCenterLinePtr()->getHShift(); + return Py::asObject(PyFloat_FromDouble(shift)); +} + +void CenterLinePy::setHorizShift(Py::Float arg) +{ + PyObject* pObj = arg.ptr(); + if (PyFloat_Check(pObj)) { + double hshift = PyFloat_AsDouble(pObj); + double vshift = getCenterLinePtr()->getVShift(); + getCenterLinePtr()->setShifts(hshift, vshift); + } else { + std::string error = std::string("type must be 'Float', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Float CenterLinePy::getVertShift() const +{ + double shift = getCenterLinePtr()->getVShift(); + return Py::asObject(PyFloat_FromDouble(shift)); +} + +void CenterLinePy::setVertShift(Py::Float arg) +{ + PyObject* pObj = arg.ptr(); + if (PyFloat_Check(pObj)) { + double vshift = PyFloat_AsDouble(pObj); + double hshift = getCenterLinePtr()->getHShift(); + getCenterLinePtr()->setShifts(hshift, vshift); + } else { + std::string error = std::string("type must be 'Float', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Float CenterLinePy::getRotation() const +{ + double rot = getCenterLinePtr()->getRotate(); + return Py::asObject(PyFloat_FromDouble(rot)); +} + +void CenterLinePy::setRotation(Py::Float arg) +{ + PyObject* pObj = arg.ptr(); + if (PyFloat_Check(pObj)) { + double rot = PyFloat_AsDouble(pObj); + getCenterLinePtr()->setRotate(rot); + } else { + std::string error = std::string("type must be 'Float', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Float CenterLinePy::getExtension() const +{ + double rot = getCenterLinePtr()->getExtend(); + return Py::asObject(PyFloat_FromDouble(rot)); +} + +void CenterLinePy::setExtension(Py::Float arg) +{ + PyObject* pObj = arg.ptr(); + if (PyFloat_Check(pObj)) { + double ext = PyFloat_AsDouble(pObj); + getCenterLinePtr()->setExtend(ext); + } else { + std::string error = std::string("type must be 'Float', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Boolean CenterLinePy::getFlip() const +{ + bool flip = getCenterLinePtr()->getFlip(); + return Py::Boolean(flip); +} + +void CenterLinePy::setFlip(Py::Boolean arg) +{ + PyObject* pObj = arg.ptr(); + if (PyBool_Check(pObj)) { + if (pObj == Py_True) { + getCenterLinePtr()->setFlip(true); + } else { + getCenterLinePtr()->setFlip(false); + } + } else { + std::string error = std::string("type must be 'Boolean', not "); + error += pObj->ob_type->tp_name; + throw Py::TypeError(error); + } +} + +Py::Object CenterLinePy::getEdges() const +{ +// Base::Console().Message("CLP::getEdges()\n"); + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + + std::vector edges = cLine->m_edges; + int size = edges.size(); + + Py::List result(size); + + for (auto& eName : edges) { + result.append(Py::asObject(PyUnicode_FromString(eName.c_str()))); + } + + return result; +} + +void CenterLinePy::setEdges(Py::Object arg) +{ +// Base::Console().Message("CLP::setEdges()\n"); + PyObject* pList = arg.ptr(); + + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + std::vector temp; + if (PyList_Check(pList)) { + int tSize = (int) PyList_Size(pList); + int i = 0; + for ( ; i < tSize; i++) { + PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); + if (PyUnicode_Check(item)) { + temp.push_back(PyUnicode_AsUTF8(item)); + } + } + cLine->m_edges = temp; + } else { + Base::Console().Error("CLPI::setEdges - input not a list!\n"); + } +} +Py::Object CenterLinePy::getFaces() const +{ +// Base::Console().Message("CLP::getFaces()\n"); + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + + std::vector faces = cLine->m_faces; + int size = faces.size(); + + Py::List result(size); + + for (auto& f: faces) { + result.append(Py::asObject(PyUnicode_FromString(f.c_str()))); + } + + return result; +} + +void CenterLinePy::setFaces(Py::Object arg) +{ +// Base::Console().Message("CLP::setFaces()\n"); + PyObject* pList = arg.ptr(); + + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + std::vector temp; + if (PyList_Check(pList)) { + int tSize = (int) PyList_Size(pList); + int i = 0; + for ( ; i < tSize; i++) { + PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); + if (PyUnicode_Check(item)) { + temp.push_back(PyUnicode_AsUTF8(item)); + } + } + cLine->m_faces = temp; + } else { + Base::Console().Error("CLPI::setFaces - input not a list!\n"); + } +} + +Py::Object CenterLinePy::getPoints() const +{ +// Base::Console().Message("CLP::getPoints()\n"); + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + + std::vector points = cLine->m_verts; + int size = points.size(); + + Py::List result(size); + + for (auto& p: points) { + result.append(Py::asObject(PyUnicode_FromString(p.c_str()))); + } + + return result; +} + +void CenterLinePy::setPoints(Py::Object arg) +{ +// Base::Console().Message("CLP::setPoints()\n"); + PyObject* pList = arg.ptr(); + + TechDraw::CenterLine* cLine= this->getCenterLinePtr(); + std::vector temp; + if (PyList_Check(pList)) { + int tSize = (int) PyList_Size(pList); + int i = 0; + for ( ; i < tSize; i++) { + PyObject* item = PyList_GetItem(pList, (Py_ssize_t) i); + if (PyUnicode_Check(item)) { + temp.push_back(PyUnicode_AsUTF8(item)); + } + } + cLine->m_verts = temp; + } else { + Base::Console().Error("CLPI::setPoints - input not a list!\n"); + } +} + +PyObject *CenterLinePy::getCustomAttributes(const char* /*attr*/) const +{ + return nullptr; +} + +int CenterLinePy::setCustomAttributes(const char* /*attr*/, PyObject* /*obj*/) +{ + return 0; +} + +#include "CenterLinePy.cpp" diff --git a/src/Mod/TechDraw/App/Cosmetic.cpp b/src/Mod/TechDraw/App/Cosmetic.cpp index 72f8be86f4..e4d82992ae 100644 --- a/src/Mod/TechDraw/App/Cosmetic.cpp +++ b/src/Mod/TechDraw/App/Cosmetic.cpp @@ -87,16 +87,16 @@ LineFormat::LineFormat(int style, void LineFormat::dump(const char* title) { - Base::Console().Message("LF::dump - %s \n",title); - Base::Console().Message("LF::dump - %s \n",toString().c_str()); + Base::Console().Message("LF::dump - %s \n", title); + Base::Console().Message("LF::dump - %s \n", toString().c_str()); } std::string LineFormat::toString() const { std::stringstream ss; - ss << m_style << "," << - m_weight << "," << - m_color.asHexString() << "," << + ss << m_style << ", " << + m_weight << ", " << + m_color.asHexString() << ", " << m_visible; return ss.str(); } @@ -130,7 +130,7 @@ CosmeticVertex::CosmeticVertex() : TechDraw::Vertex() permaPoint = Base::Vector3d(0.0, 0.0, 0.0); linkGeom = -1; color = Preferences::vertexColor(); - size = Preferences::vertexScale() * + size = Preferences::vertexScale() * LineGroup::getDefaultWidth("Thin"); style = 1; visible = true; @@ -159,7 +159,7 @@ CosmeticVertex::CosmeticVertex(Base::Vector3d loc) : TechDraw::Vertex(loc) permaPoint = loc; linkGeom = -1; color = Preferences::vertexColor(); - size = Preferences::vertexScale() * + size = Preferences::vertexScale() * LineGroup::getDefaultWidth("Thick"); style = 1; //TODO: implement styled vertexes visible = true; @@ -183,21 +183,21 @@ void CosmeticVertex::moveRelative(Base::Vector3d movement) std::string CosmeticVertex::toString() const { std::stringstream ss; - ss << permaPoint.x << "," << - permaPoint.y << "," << - permaPoint.z << "," << + ss << permaPoint.x << ", " << + permaPoint.y << ", " << + permaPoint.z << ", " << " / "; - ss << point().x << "," << - point().y << "," << - point().z << "," << + ss << point().x << ", " << + point().y << ", " << + point().z << ", " << " / " << - linkGeom << "," << + linkGeom << ", " << " / " << - color.asHexString() << "," << + color.asHexString() << ", " << " / " << - size << "," << + size << ", " << " / " << - style << "," << + style << ", " << " / " << visible << " / " ; ss << getTagAsString(); @@ -311,7 +311,7 @@ PyObject* CosmeticVertex::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new CosmeticVertexPy(this),true); + PythonObject = Py::Object(new CosmeticVertexPy(this), true); } return Py::new_reference_to(PythonObject); } @@ -319,13 +319,13 @@ PyObject* CosmeticVertex::getPyObject() void CosmeticVertex::dump(const char* title) { - Base::Console().Message("CV::dump - %s \n",title); - Base::Console().Message("CV::dump - %s \n",toString().c_str()); + Base::Console().Message("CV::dump - %s \n", title); + Base::Console().Message("CV::dump - %s \n", toString().c_str()); } //****************************************** -TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge,Base::Persistence) +TYPESYSTEM_SOURCE(TechDraw::CosmeticEdge, Base::Persistence) //note this ctor has no occEdge or first/last point for geometry! CosmeticEdge::CosmeticEdge() @@ -343,7 +343,7 @@ CosmeticEdge::CosmeticEdge(CosmeticEdge* ce) //these endpoints are already YInverted permaStart = ce->permaStart; permaEnd = ce->permaEnd; - permaRadius = ce->permaRadius; + permaRadius = ce->permaRadius; m_geometry = newGeom; m_format = ce->m_format; initialize(); @@ -373,7 +373,7 @@ CosmeticEdge::CosmeticEdge(TechDraw::BaseGeomPtr g) permaStart = circ->center; permaEnd = circ->center; permaRadius = circ->radius; - } + } initialize(); } @@ -395,11 +395,11 @@ void CosmeticEdge::initialize() TopoDS_Edge CosmeticEdge::TopoDS_EdgeFromVectors(Base::Vector3d pt1, Base::Vector3d pt2) { - // Base::Console().Message("CE::CE(p1,p2)\n"); + // Base::Console().Message("CE::CE(p1, p2)\n"); Base::Vector3d p1 = DrawUtil::invertY(pt1); Base::Vector3d p2 = DrawUtil::invertY(pt2); - gp_Pnt gp1(p1.x,p1.y,p1.z); - gp_Pnt gp2(p2.x,p2.y,p2.z); + gp_Pnt gp1(p1.x, p1.y, p1.z); + gp_Pnt gp2(p2.x, p2.y, p2.z); TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); return e; } @@ -423,10 +423,10 @@ std::string CosmeticEdge::toString() const std::stringstream ss; ss << getTagAsString() << ", $$$, "; if (m_geometry) { - ss << m_geometry->geomType << - ",$$$," << + ss << m_geometry->geomType << + ", $$$, " << m_geometry->toString() << - ",$$$," << + ", $$$, " << m_format.toString(); } return ss.str(); @@ -434,8 +434,8 @@ std::string CosmeticEdge::toString() const void CosmeticEdge::dump(const char* title) { - Base::Console().Message("CE::dump - %s \n",title); - Base::Console().Message("CE::dump - %s \n",toString().c_str()); + Base::Console().Message("CE::dump - %s \n", title); + Base::Console().Message("CE::dump - %s \n", toString().c_str()); } // Persistence implementers @@ -568,7 +568,7 @@ PyObject* CosmeticEdge::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new CosmeticEdgePy(this),true); + PythonObject = Py::Object(new CosmeticEdgePy(this), true); } return Py::new_reference_to(PythonObject); } @@ -576,7 +576,7 @@ PyObject* CosmeticEdge::getPyObject() //********************************************************* -TYPESYSTEM_SOURCE(TechDraw::CenterLine,Base::Persistence) +TYPESYSTEM_SOURCE(TechDraw::CenterLine, Base::Persistence) CenterLine::CenterLine() { @@ -613,7 +613,7 @@ CenterLine::CenterLine(TechDraw::CenterLine* cl) } CenterLine::CenterLine(TechDraw::BaseGeomPtr bg, - int m, + int m, double h, double v, double r, @@ -661,18 +661,18 @@ void CenterLine::initialize() TechDraw::BaseGeomPtr CenterLine::BaseGeomPtrFromVectors(Base::Vector3d pt1, Base::Vector3d pt2) { - // Base::Console().Message("CE::CE(p1,p2)\n"); + // Base::Console().Message("CE::CE(p1, p2)\n"); Base::Vector3d p1 = DrawUtil::invertY(pt1); Base::Vector3d p2 = DrawUtil::invertY(pt2); - gp_Pnt gp1(p1.x,p1.y,p1.z); - gp_Pnt gp2(p2.x,p2.y,p2.z); + gp_Pnt gp1(p1.x, p1.y, p1.z); + gp_Pnt gp2(p2.x, p2.y, p2.z); TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); TechDraw::BaseGeomPtr bg = TechDraw::BaseGeom::baseFactory(e); return bg; } -CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, - std::vector subNames, +CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, + std::vector subNames, int mode, bool flip) { @@ -681,7 +681,7 @@ CenterLine* CenterLine::CenterLineBuilder(DrawViewPart* partFeat, std::vector faces; std::vector edges; std::vector verts; - + std::string geomType = TechDraw::DrawUtil::getGeomTypeFromName(subNames.front()); int type = CLTYPE::FACE; if (geomType == "Face") { @@ -739,12 +739,12 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea // Base::Console().Message("CL::scaledGeometry - no geometry to scale!\n"); //CenterLine was created by points without a geometry reference, ends = calcEndPointsNoRef(m_start, m_end, scale, m_extendBy, - m_hShift,m_vShift, m_rotate); + m_hShift, m_vShift, m_rotate); } else if (m_type == CLTYPE::FACE) { ends = calcEndPoints(partFeat, m_faces, m_mode, m_extendBy, - m_hShift,m_vShift, m_rotate); + m_hShift, m_vShift, m_rotate); } else if (m_type == CLTYPE::EDGE) { ends = calcEndPoints2Lines(partFeat, m_edges, @@ -770,11 +770,11 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea if (p1.IsEqual(p2, 0.00001)) { Base::Console().Warning("Centerline endpoints are equal. Could not draw.\n"); //what to do here? //return current geom? - return m_geometry; + return m_geometry; } - gp_Pnt gp1(p1.x,p1.y,p1.z); - gp_Pnt gp2(p2.x,p2.y,p2.z); + gp_Pnt gp1(p1.x, p1.y, p1.z); + gp_Pnt gp2(p2.x, p2.y, p2.z); TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); TopoDS_Shape s = TechDraw::scaleShape(e, scale); TopoDS_Edge newEdge = TopoDS::Edge(s); @@ -784,48 +784,48 @@ TechDraw::BaseGeomPtr CenterLine::scaledGeometry(TechDraw::DrawViewPart* partFea newGeom->cosmetic = true; newGeom->source(CENTERLINE); newGeom->setCosmeticTag(getTagAsString()); - + return newGeom; } std::string CenterLine::toString() const { std::stringstream ss; - ss << m_start.x << "," << - m_start.y << "," << - m_start.z << "," << - m_end.x << "," << - m_end.y << "," << - m_end.z << "," << - m_mode << "," << - m_type << "," << - m_hShift << "," << - m_vShift << "," << - m_rotate << "," << - m_flip2Line << "," << - m_extendBy << "," << + ss << m_start.x << ", " << + m_start.y << ", " << + m_start.z << ", " << + m_end.x << ", " << + m_end.y << ", " << + m_end.z << ", " << + m_mode << ", " << + m_type << ", " << + m_hShift << ", " << + m_vShift << ", " << + m_rotate << ", " << + m_flip2Line << ", " << + m_extendBy << ", " << m_faces.size(); if (!m_faces.empty()) { for (auto& f: m_faces) { if (!f.empty()) { - ss << "," << f ; + ss << ", " << f ; } } } std::string clCSV = ss.str(); std::string fmtCSV = m_format.toString(); - return clCSV + ",$$$," + fmtCSV; + return clCSV + ", $$$, " + fmtCSV; } void CenterLine::dump(const char* title) { - Base::Console().Message("CL::dump - %s \n",title); - Base::Console().Message("CL::dump - %s \n",toString().c_str()); + Base::Console().Message("CL::dump - %s \n", title); + Base::Console().Message("CL::dump - %s \n", toString().c_str()); } std::tuple CenterLine::rotatePointsAroundMid(Base::Vector3d p1, Base::Vector3d p2, Base::Vector3d mid, double rotate) { - //rotate p1, p2 about mid + //rotate p1, p2 about mid double revRotate = -rotate; double cosTheta = cos(revRotate * M_PI / 180.0); double sinTheta = sin(revRotate * M_PI / 180.0); @@ -888,7 +888,7 @@ std::pair CenterLine::calcEndPointsNoRef( //end points for face centerline std::pair CenterLine::calcEndPoints(DrawViewPart* partFeat, - std::vector faceNames, + std::vector faceNames, int mode, double ext, double hShift, double vShift, double rotate) @@ -909,7 +909,7 @@ std::pair CenterLine::calcEndPoints(DrawViewPart continue; } int idx = TechDraw::DrawUtil::getIndexFromName(fn); - std::vector faceEdges = + std::vector faceEdges = partFeat->getFaceEdgesByIndex(idx); if (!faceEdges.empty()) { for (auto& fe: faceEdges) { @@ -926,8 +926,8 @@ std::pair CenterLine::calcEndPoints(DrawViewPart throw Base::IndexError("CenterLine wrong number of faces."); } - double Xmin,Ymin,Zmin,Xmax,Ymax,Zmax; - faceBox.Get(Xmin,Ymin,Zmin,Xmax,Ymax,Zmax); + double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax; + faceBox.Get(Xmin, Ymin, Zmin, Xmax, Ymax, Zmax); double Xspan = fabs(Xmax - Xmin); Xspan = (Xspan / 2.0); @@ -943,13 +943,13 @@ std::pair CenterLine::calcEndPoints(DrawViewPart p2 = Base::Vector3d(Xmid, Ymin, 0.0); } else if (mode == 1) { //horizontal p1 = Base::Vector3d(Xmin, Ymid, 0.0); - p2 = Base::Vector3d(Xmax,Ymid, 0.0); + p2 = Base::Vector3d(Xmax, Ymid, 0.0); } else { //vert == 2 //aligned, but aligned doesn't make sense for face(s) bbox Base::Console().Message("CL::calcEndPoints - aligned is not applicable to Face center lines\n"); p1 = Base::Vector3d(Xmid, Ymax, 0.0); p2 = Base::Vector3d(Xmid, Ymin, 0.0); } - + Base::Vector3d mid = (p1 + p2) / 2.0; //extend @@ -983,11 +983,11 @@ std::pair CenterLine::calcEndPoints(DrawViewPart } std::pair CenterLine::calcEndPoints2Lines(DrawViewPart* partFeat, - std::vector edgeNames, + std::vector edgeNames, int mode, double ext, double hShift, double vShift, double rotate, bool flip) - + { Q_UNUSED(flip) @@ -1060,7 +1060,7 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi //rotate if (!DrawUtil::fpCompare(rotate, 0.0)) { - //rotate p1, p2 about mid + //rotate p1, p2 about mid tie(p1, p2) = rotatePointsAroundMid(p1, p2, mid, rotate); } @@ -1082,11 +1082,11 @@ std::pair CenterLine::calcEndPoints2Lines(DrawVi } std::pair CenterLine::calcEndPoints2Points(DrawViewPart* partFeat, - std::vector vertNames, + std::vector vertNames, int mode, double ext, double hShift, double vShift, double rotate, bool flip) - + { // Base::Console().Message("CL::calc2Points()\n"); if (vertNames.empty()) { @@ -1131,7 +1131,7 @@ std::pair CenterLine::calcEndPoints2Points(DrawV p1 = p2; p2 = temp; } - + if (mode == 0) { //Vertical p1.x = mid.x; p2.x = mid.x; @@ -1365,14 +1365,14 @@ void CenterLine::Restore(Base::XMLReader &reader) m_geometry = aoc; } else { Base::Console().Warning("CL::Restore - unimplemented geomType: %d\n", gType); - } + } } CenterLine* CenterLine::copy() const { CenterLine* newCL = new CenterLine(); newCL->m_start = m_start; - newCL->m_end = m_end; + newCL->m_end = m_end; newCL->m_mode = m_mode; newCL->m_hShift = m_hShift; newCL->m_vShift = m_vShift; @@ -1384,7 +1384,7 @@ CenterLine* CenterLine::copy() const newCL->m_faces = m_faces; newCL->m_edges = m_edges; newCL->m_verts = m_verts; - + TechDraw::BaseGeomPtr newGeom = m_geometry->copy(); newCL->m_geometry = newGeom; @@ -1439,7 +1439,7 @@ PyObject* CenterLine::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new CenterLinePy(this),true); + PythonObject = Py::Object(new CenterLinePy(this), true); } return Py::new_reference_to(PythonObject); } @@ -1492,7 +1492,7 @@ bool CenterLine::getFlip() } //------------------------------------------------------------------------------ -TYPESYSTEM_SOURCE(TechDraw::GeomFormat,Base::Persistence) +TYPESYSTEM_SOURCE(TechDraw::GeomFormat, Base::Persistence) GeomFormat::GeomFormat() : m_geomIndex(-1) @@ -1505,7 +1505,7 @@ GeomFormat::GeomFormat() : createNewTag(); } -GeomFormat::GeomFormat(GeomFormat* gf) +GeomFormat::GeomFormat(GeomFormat* gf) { m_geomIndex = gf->m_geomIndex; m_format.m_style = gf->m_format.m_style; @@ -1534,14 +1534,14 @@ GeomFormat::~GeomFormat() void GeomFormat::dump(const char* title) const { - Base::Console().Message("GF::dump - %s \n",title); - Base::Console().Message("GF::dump - %s \n",toString().c_str()); + Base::Console().Message("GF::dump - %s \n", title); + Base::Console().Message("GF::dump - %s \n", toString().c_str()); } std::string GeomFormat::toString() const { std::stringstream ss; - ss << m_geomIndex << ",$$$," << + ss << m_geomIndex << ", $$$, " << m_format.toString(); return ss.str(); } @@ -1639,7 +1639,7 @@ PyObject* GeomFormat::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new GeomFormatPy(this),true); + PythonObject = Py::Object(new GeomFormatPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/Cosmetic.h b/src/Mod/TechDraw/App/Cosmetic.h index dc0a5d3ad1..ef8b46355d 100644 --- a/src/Mod/TechDraw/App/Cosmetic.h +++ b/src/Mod/TechDraw/App/Cosmetic.h @@ -28,6 +28,7 @@ #include #include +#include #include #include @@ -148,7 +149,7 @@ public: CosmeticEdge* clone() const; Base::Vector3d permaStart; //persistent unscaled start/end points in View coords - Base::Vector3d permaEnd; + Base::Vector3d permaEnd; double permaRadius; // void unscaleEnds(double scale); TechDraw::BaseGeomPtr m_geometry; @@ -191,13 +192,13 @@ public: CenterLine(CenterLine* cl); //set m_faces after using next 3 ctors CenterLine(TechDraw::BaseGeomPtr bg, - int m = CLMODE::VERTICAL, + int m = CLMODE::VERTICAL, double h = 0.0, double v = 0.0, double r = 0.0, double x = 0.0); CenterLine(Base::Vector3d p1, Base::Vector3d p2, - int m = CLMODE::VERTICAL, + int m = CLMODE::VERTICAL, double h = 0.0, double v = 0.0, double r = 0.0, @@ -288,7 +289,7 @@ public: protected: void initialize(); - + void createNewTag(); void assignTag(const TechDraw::CenterLine* cl); diff --git a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp index 8890525326..a8fb25e222 100644 --- a/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp +++ b/src/Mod/TechDraw/App/CosmeticEdgePyImp.cpp @@ -132,19 +132,19 @@ void CosmeticEdgePy::setFormat(Py::Object arg) double weight = 0.50; double red = 0.0, green = 0.0, blue = 0.0, alpha = 0.0; App::Color c(red, blue, green, alpha); - bool visible = 1; - + bool visible = 1; + TechDraw::CosmeticEdge* ce = this->getCosmeticEdgePtr(); if (PyTuple_Check(pTuple)) { int tSize = (int) PyTuple_Size(pTuple); if (tSize > 3) { - PyObject* pStyle = PyTuple_GetItem(pTuple,0); + PyObject* pStyle = PyTuple_GetItem(pTuple, 0); style = (int) PyLong_AsLong(pStyle); - PyObject* pWeight = PyTuple_GetItem(pTuple,1); + PyObject* pWeight = PyTuple_GetItem(pTuple, 1); weight = PyFloat_AsDouble(pWeight); - PyObject* pColor = PyTuple_GetItem(pTuple,2); + PyObject* pColor = PyTuple_GetItem(pTuple, 2); c = DrawUtil::pyTupleToColor(pColor); - PyObject* pVisible = PyTuple_GetItem(pTuple,3); + PyObject* pVisible = PyTuple_GetItem(pTuple, 3); visible = (bool) PyLong_AsLong(pVisible); ce->m_format.m_style = style; @@ -236,8 +236,8 @@ void CosmeticEdgePy::setStart(Py::Object arg) pNew = DrawUtil::invertY(pNew); Base::Vector3d pEnd = getCosmeticEdgePtr()->permaEnd; - gp_Pnt gp1(pNew.x,pNew.y,pNew.z); - gp_Pnt gp2(pEnd.x,pEnd.y,pEnd.z); + gp_Pnt gp1(pNew.x, pNew.y, pNew.z); + gp_Pnt gp2(pEnd.x, pEnd.y, pEnd.z); TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp1, gp2); // auto oldGeom = getCosmeticEdgePtr()->m_geometry; getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e); @@ -270,8 +270,8 @@ void CosmeticEdgePy::setEnd(Py::Object arg) pNew = DrawUtil::invertY(pNew); Base::Vector3d pStart = getCosmeticEdgePtr()->permaStart; - gp_Pnt gp1(pNew.x,pNew.y,pNew.z); - gp_Pnt gp2(pStart.x,pStart.y,pStart.z); + gp_Pnt gp1(pNew.x, pNew.y, pNew.z); + gp_Pnt gp2(pStart.x, pStart.y, pStart.z); TopoDS_Edge e = BRepBuilderAPI_MakeEdge(gp2, gp1); // auto oldGeom = getCosmeticEdgePtr()->m_geometry; getCosmeticEdgePtr()->m_geometry = TechDraw::BaseGeom::baseFactory(e); diff --git a/src/Mod/TechDraw/App/CosmeticExtension.cpp b/src/Mod/TechDraw/App/CosmeticExtension.cpp index 0a4e98e1d1..c7b8bd3123 100644 --- a/src/Mod/TechDraw/App/CosmeticExtension.cpp +++ b/src/Mod/TechDraw/App/CosmeticExtension.cpp @@ -43,32 +43,32 @@ using namespace std; EXTENSION_PROPERTY_SOURCE(TechDraw::CosmeticExtension, App::DocumentObjectExtension) -CosmeticExtension::CosmeticExtension() +CosmeticExtension::CosmeticExtension() { static const char *cgroup = "Cosmetics"; EXTENSION_ADD_PROPERTY_TYPE(CosmeticVertexes, (nullptr), cgroup, App::Prop_Output, "CosmeticVertex Save/Restore"); EXTENSION_ADD_PROPERTY_TYPE(CosmeticEdges, (nullptr), cgroup, App::Prop_Output, "CosmeticEdge Save/Restore"); - EXTENSION_ADD_PROPERTY_TYPE(CenterLines ,(nullptr),cgroup,App::Prop_Output,"Geometry format Save/Restore"); - EXTENSION_ADD_PROPERTY_TYPE(GeomFormats ,(nullptr),cgroup,App::Prop_Output,"Geometry format Save/Restore"); + EXTENSION_ADD_PROPERTY_TYPE(CenterLines ,(nullptr), cgroup, App::Prop_Output, "Geometry format Save/Restore"); + EXTENSION_ADD_PROPERTY_TYPE(GeomFormats ,(nullptr), cgroup, App::Prop_Output, "Geometry format Save/Restore"); initExtensionType(CosmeticExtension::getExtensionClassTypeId()); } -CosmeticExtension::~CosmeticExtension() +CosmeticExtension::~CosmeticExtension() { } -//void CosmeticExtension::extHandleChangedPropertyName(Base::XMLReader &reader, -// const char* TypeName, +//void CosmeticExtension::extHandleChangedPropertyName(Base::XMLReader &reader, +// const char* TypeName, // const char* PropName) //{ //} //============================================================================== -//CosmeticVertex x,y are stored as unscaled, but mirrored (inverted Y) values. -//if you are creating a CV based on calculations of scaled geometry, you need to -//unscale x,y before creation. +//CosmeticVertex x, y are stored as unscaled, but mirrored (inverted Y) values. +//if you are creating a CV based on calculations of scaled geometry, you need to +//unscale x, y before creation. //if you are creating a CV based on calculations of mirrored geometry, you need to //mirror again before creation. @@ -107,7 +107,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertex(std::string tagSt // used when selecting TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::string name) const { -// Base::Console().Message("CEx::getCVBySelection(%s)\n",name.c_str()); +// Base::Console().Message("CEx::getCVBySelection(%s)\n", name.c_str()); CosmeticVertex* result = nullptr; App::DocumentObject* extObj = const_cast (getExtendedObject()); TechDraw::DrawViewPart* dvp = dynamic_cast(extObj); @@ -122,7 +122,7 @@ TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(std::s return result; } -//overload for index only +//overload for index only TechDraw::CosmeticVertex* CosmeticExtension::getCosmeticVertexBySelection(int i) const { // Base::Console().Message("CEx::getCVBySelection(%d)\n", i); @@ -159,7 +159,7 @@ void CosmeticExtension::removeCosmeticVertex(std::vector delTags) std::string CosmeticExtension::addCosmeticEdge(Base::Vector3d start, Base::Vector3d end) { -// Base::Console().Message("CEx::addCosmeticEdge(s,e)\n"); +// Base::Console().Message("CEx::addCosmeticEdge(s, e)\n"); std::vector edges = CosmeticEdges.getValues(); TechDraw::CosmeticEdge* ce = new TechDraw::CosmeticEdge(start, end); edges.push_back(ce); @@ -204,7 +204,7 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdge(std::string tagString // used when selecting TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::string name) const { -// Base::Console().Message("CEx::getCEBySelection(%s)\n",name.c_str()); +// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str()); CosmeticEdge* result = nullptr; App::DocumentObject* extObj = const_cast (getExtendedObject()); TechDraw::DrawViewPart* dvp = dynamic_cast(extObj); @@ -214,13 +214,13 @@ TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(std::strin TechDraw::BaseGeomPtr base = dvp->getGeomByIndex(idx); if (!base) return result; - + if (!base->getCosmeticTag().empty()) result = getCosmeticEdge(base->getCosmeticTag()); return result; } -//overload for index only +//overload for index only TechDraw::CosmeticEdge* CosmeticExtension::getCosmeticEdgeBySelection(int i) const { // Base::Console().Message("CEx::getCEBySelection(%d)\n", i); @@ -311,7 +311,7 @@ TechDraw::CenterLine* CosmeticExtension::getCenterLine(std::string tagString) co // used when selecting TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string name) const { -// Base::Console().Message("CEx::getCLBySelection(%s)\n",name.c_str()); +// Base::Console().Message("CEx::getCLBySelection(%s)\n", name.c_str()); CenterLine* result = nullptr; App::DocumentObject* extObj = const_cast (getExtendedObject()); TechDraw::DrawViewPart* dvp = dynamic_cast(extObj); @@ -326,7 +326,7 @@ TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(std::string na return result; } -//overload for index only +//overload for index only TechDraw::CenterLine* CosmeticExtension::getCenterLineBySelection(int i) const { // Base::Console().Message("CEx::getCLBySelection(%d)\n", i); @@ -392,7 +392,7 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormat(std::string tagString) co // used when selecting TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string name) const { -// Base::Console().Message("CEx::getCEBySelection(%s)\n",name.c_str()); +// Base::Console().Message("CEx::getCEBySelection(%s)\n", name.c_str()); GeomFormat* result = nullptr; App::DocumentObject* extObj = const_cast (getExtendedObject()); TechDraw::DrawViewPart* dvp = dynamic_cast(extObj); @@ -409,7 +409,7 @@ TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(std::string na return result; } -//overload for index only +//overload for index only TechDraw::GeomFormat* CosmeticExtension::getGeomFormatBySelection(int i) const { // Base::Console().Message("CEx::getCEBySelection(%d)\n", i); @@ -436,7 +436,7 @@ void CosmeticExtension::removeGeomFormat(std::string delTag) PyObject* CosmeticExtension::getExtensionPyObject(void) { if (ExtensionPythonObject.is(Py::_None())){ // ref counter is set to 1 - ExtensionPythonObject = Py::Object(new CosmeticExtensionPy(this),true); + ExtensionPythonObject = Py::Object(new CosmeticExtensionPy(this), true); } return Py::new_reference_to(ExtensionPythonObject); } diff --git a/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp b/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp index 56864a1a3d..e30dbdf4c9 100644 --- a/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp +++ b/src/Mod/TechDraw/App/CosmeticVertexPyImp.cpp @@ -135,12 +135,12 @@ void CosmeticVertexPy::setPoint(Py::Object arg) PyObject* p = arg.ptr(); if (PyObject_TypeCheck(p, &(Base::VectorPy::Type))) { Base::Vector3d point = static_cast(p)->value(); - getCosmeticVertexPtr()->permaPoint = + getCosmeticVertexPtr()->permaPoint = DrawUtil::invertY(point); } else if (PyObject_TypeCheck(p, &PyTuple_Type)) { Base::Vector3d point = Base::getVectorFromTuple(p); - getCosmeticVertexPtr()->permaPoint = + getCosmeticVertexPtr()->permaPoint = DrawUtil::invertY(point); } else { diff --git a/src/Mod/TechDraw/App/DrawDimHelper.cpp b/src/Mod/TechDraw/App/DrawDimHelper.cpp index 0a1ff0e248..1b12997f8a 100644 --- a/src/Mod/TechDraw/App/DrawDimHelper.cpp +++ b/src/Mod/TechDraw/App/DrawDimHelper.cpp @@ -203,7 +203,7 @@ std::pair DrawDimHelper::minMax(DrawViewPart* dv } //can't use Bnd_Box2d here as BndLib_Add2dCurve::Add adds the poles of splines to the box. - //poles are not necessarily on the curve! 3d Bnd_Box does it properly. + //poles are not necessarily on the curve! 3d Bnd_Box does it properly. //this has to be the bbx of the selected edges, not the dvp!!! double minX, minY, minZ, maxX, maxY, maxZ; edgeBbx.Get(minX, minY, minZ, maxX, maxY, maxZ); @@ -236,7 +236,7 @@ std::pair DrawDimHelper::minMax(DrawViewPart* dv Handle(Geom2d_Line) boundaryTop = new Geom2d_Line(topMid, xDir); gp_Pnt2d topPoint = findClosestPoint(hTCurve2dList, boundaryTop); - refMin = Base::Vector3d(bottomPoint.X(),bottomPoint.Y(), 0.0); + refMin = Base::Vector3d(bottomPoint.X(), bottomPoint.Y(), 0.0); refMax = Base::Vector3d(topPoint.X(), topPoint.Y(), 0.0); } @@ -352,7 +352,7 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp, Base::Vector3d cleanMin = DrawUtil::invertY(inMin); std::string tag1 = dvp->addCosmeticVertex(cleanMin); int iGV1 = dvp->add1CVToGV(tag1); - + Base::Vector3d cleanMax = DrawUtil::invertY(inMax); std::string tag2 = dvp->addCosmeticVertex(cleanMax); int iGV2 = dvp->add1CVToGV(tag2); @@ -374,11 +374,11 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp, objs.push_back(dvp); if (extent) { - Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimExtent','%s')", + Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimExtent', '%s')", dimName.c_str()); } else { - Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')", + Base::Interpreter().runStringArg("App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", dimName.c_str()); } @@ -386,7 +386,7 @@ DrawViewDimension* DrawDimHelper::makeDistDim(DrawViewPart* dvp, dimName.c_str(), dimType.c_str()); Base::Interpreter().runStringArg("App.activeDocument().%s.addView(App.activeDocument().%s)", - pageName.c_str(),dimName.c_str()); + pageName.c_str(), dimName.c_str()); dim = dynamic_cast(doc->getObject(dimName.c_str())); if (!dim) { diff --git a/src/Mod/TechDraw/App/DrawDimHelper.h b/src/Mod/TechDraw/App/DrawDimHelper.h index 438e009032..e404920d0c 100644 --- a/src/Mod/TechDraw/App/DrawDimHelper.h +++ b/src/Mod/TechDraw/App/DrawDimHelper.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawDimHelper_h_ -#define _DrawDimHelper_h_ +#ifndef DrawDimHelper_h_ +#define DrawDimHelper_h_ #include @@ -43,7 +43,7 @@ class TechDrawExport hTrimCurve { hTrimCurve(Handle(Geom2d_Curve) hCurveIn, double parm1, double parm2); - ~hTrimCurve() {} + ~hTrimCurve() = default; Handle(Geom2d_Curve) hCurve; double first; diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.cpp b/src/Mod/TechDraw/App/DrawGeomHatch.cpp index 0b7d234695..5ab7ef73d0 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.cpp +++ b/src/Mod/TechDraw/App/DrawGeomHatch.cpp @@ -95,13 +95,13 @@ DrawGeomHatch::DrawGeomHatch() { static const char *vgroup = "GeomHatch"; - ADD_PROPERTY_TYPE(Source,(nullptr),vgroup,(App::PropertyType)(App::Prop_None),"The View + Face to be crosshatched"); + ADD_PROPERTY_TYPE(Source, (nullptr), vgroup, (App::PropertyType)(App::Prop_None), "The View + Face to be crosshatched"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(FilePattern ,(prefGeomHatchFile()),vgroup,App::Prop_None,"The crosshatch pattern file for this area"); - ADD_PROPERTY_TYPE(PatIncluded, (""), vgroup,App::Prop_None, + ADD_PROPERTY_TYPE(FilePattern ,(prefGeomHatchFile()), vgroup, App::Prop_None, "The crosshatch pattern file for this area"); + ADD_PROPERTY_TYPE(PatIncluded, (""), vgroup, App::Prop_None, "Embedded Pat hatch file. System use only."); // n/a to end users - ADD_PROPERTY_TYPE(NamePattern,(prefGeomHatchName()),vgroup,App::Prop_None,"The name of the pattern"); - ADD_PROPERTY_TYPE(ScalePattern,(1.0),vgroup,App::Prop_None,"GeomHatch pattern size adjustment"); + ADD_PROPERTY_TYPE(NamePattern, (prefGeomHatchName()), vgroup, App::Prop_None, "The name of the pattern"); + ADD_PROPERTY_TYPE(ScalePattern, (1.0), vgroup, App::Prop_None, "GeomHatch pattern size adjustment"); ScalePattern.setConstraints(&scaleRange); m_saveFile = ""; @@ -112,10 +112,6 @@ DrawGeomHatch::DrawGeomHatch() } -DrawGeomHatch::~DrawGeomHatch() -{ -} - void DrawGeomHatch::onChanged(const App::Property* prop) { if (!isRestoring()) { @@ -212,7 +208,7 @@ std::vector DrawGeomHatch::getDecodedSpecsFromFile() { std::string fileSpec = PatIncluded.getValue(); std::string myPattern = NamePattern.getValue(); - return getDecodedSpecsFromFile(fileSpec,myPattern); + return getDecodedSpecsFromFile(fileSpec, myPattern); } @@ -223,10 +219,10 @@ std::vector DrawGeomHatch::getDecodedSpecsFromFile(std::string file std::vector result; Base::FileInfo fi(fileSpec); if (!fi.isReadable()) { - Base::Console().Error("DrawGeomHatch::getDecodedSpecsFromFile not able to open %s!\n",fileSpec.c_str()); + Base::Console().Error("DrawGeomHatch::getDecodedSpecsFromFile not able to open %s!\n", fileSpec.c_str()); return result; } - result = PATLineSpec::getSpecsForPattern(fileSpec,myPattern); + result = PATLineSpec::getSpecsForPattern(fileSpec, myPattern); return result; } @@ -240,7 +236,7 @@ std::vector DrawGeomHatch::getTrimmedLines(int i) //get the trimmed Base::Console().Log("DGH::getTrimmedLines - no source geometry\n"); return result; } - return getTrimmedLines(source, m_lineSets,i, ScalePattern.getValue()); + return getTrimmedLines(source, m_lineSets, i, ScalePattern.getValue()); } /* static */ @@ -252,7 +248,7 @@ std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou std::vector result; gp_Pln p; Base::Vector3d vfc = DrawUtil::getFaceCenter(f); - gp_Pnt fc(vfc.x, vfc.y, vfc.z); + gp_Pnt fc(vfc.x, vfc.y, vfc.z); double dir = -1.0; if (fc.Z() < 0.0) { dir = -dir; @@ -260,7 +256,7 @@ std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou Base::Vector3d stdZ(0.0, 0.0, 1.0); Base::Vector3d offset = stdZ * p.Distance(fc) * dir; - //f may be above or below paper plane and must be moved so Common operation in + //f may be above or below paper plane and must be moved so Common operation in //getTrimmedLines succeeds TopoDS_Shape moved = TechDraw::moveShape(f, offset); @@ -275,7 +271,7 @@ std::vector DrawGeomHatch::getTrimmedLinesSection(DrawViewSection* sou //! get hatch lines trimmed to face outline std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, std::vector lineSets, int iface, double scale ) { - TopoDS_Face face = extractFace(source,iface); + TopoDS_Face face = extractFace(source, iface); std::vector result = getTrimmedLines(source, lineSets, face, @@ -314,7 +310,7 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, builder.Add(grid, c); } - //Common(Compound,Face) + //Common(Compound, Face) BRepAlgoAPI_Common mkCommon(face, grid); if ((!mkCommon.IsDone()) || (mkCommon.Shape().IsNull()) ) { @@ -336,7 +332,7 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, for ( int i = 1 ; i <= mapOfEdges.Extent() ; i++ ) { //remember, TopExp makes no promises about the order it finds edges const TopoDS_Edge& edge = TopoDS::Edge(mapOfEdges(i)); if (edge.IsNull()) { - Base::Console().Log("INFO - DGH::getTrimmedLines - edge: %d is NULL\n",i); + Base::Console().Log("INFO - DGH::getTrimmedLines - edge: %d is NULL\n", i); continue; } resultEdges.push_back(edge); @@ -347,7 +343,7 @@ std::vector DrawGeomHatch::getTrimmedLines(DrawViewPart* source, for (auto& e: resultEdges) { TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e); if (!base) { - Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n",i); + Base::Console().Log("FAIL - DGH::getTrimmedLines - baseFactory failed for edge: %d\n", i); throw Base::ValueError("DGH::getTrimmedLines - baseFactory failed"); } resultGeoms.push_back(base); @@ -365,8 +361,8 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box { std::vector result; - double minX,maxX,minY,maxY,minZ,maxZ; - b.Get(minX,minY,minZ,maxX,maxY,maxZ); + double minX, maxX, minY, maxY, minZ, maxZ; + b.Get(minX, minY, minZ, maxX, maxY, maxZ); Base::Vector3d start; Base::Vector3d end; @@ -392,9 +388,9 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box // make repeats for (int i = 0; i < repeatTotal; i++) { - Base::Vector3d newStart(minX,yStart + float(i)*interval,0); - Base::Vector3d newEnd(maxX,yStart + float(i)*interval,0); - TopoDS_Edge newLine = makeLine(newStart,newEnd); + Base::Vector3d newStart(minX, yStart + float(i)*interval, 0); + Base::Vector3d newEnd(maxX, yStart + float(i)*interval, 0); + TopoDS_Edge newLine = makeLine(newStart, newEnd); result.push_back(newLine); } } else if ((angle == 90.0) || @@ -408,14 +404,14 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box // make repeats for (int i = 0; i < repeatTotal; i++) { - Base::Vector3d newStart(xStart + float(i)*interval,minY,0); - Base::Vector3d newEnd(xStart + float(i)*interval,maxY,0); - TopoDS_Edge newLine = makeLine(newStart,newEnd); + Base::Vector3d newStart(xStart + float(i)*interval, minY, 0); + Base::Vector3d newEnd(xStart + float(i)*interval, maxY, 0); + TopoDS_Edge newLine = makeLine(newStart, newEnd); result.push_back(newLine); } //TODO: check if this makes 2-3 extra lines. might be some "left" lines on "right" side of vv } else if (angle > 0) { //oblique (bottom left -> top right) - //ex: 60,0,0,0,4.0,25,-25 + //ex: 60, 0,0, 0,4.0, 25, -25 // Base::Console().Message("TRACE - DGH-makeEdgeOverlay - making angle > 0\n"); double xLeftAtom = origin.x + (minY - origin.y)/slope; //the "atom" is the fill line that passes through the //pattern-origin (not necc. R2 origin) @@ -429,13 +425,13 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box //make repeats for (int i = 0; i < repeatTotal; i++) { - Base::Vector3d newStart(leftStartX + (float(i) * interval),minY,0); - Base::Vector3d newEnd (leftEndX + (float(i) * interval),maxY,0); - TopoDS_Edge newLine = makeLine(newStart,newEnd); + Base::Vector3d newStart(leftStartX + (float(i) * interval), minY, 0); + Base::Vector3d newEnd (leftEndX + (float(i) * interval), maxY, 0); + TopoDS_Edge newLine = makeLine(newStart, newEnd); result.push_back(newLine); } } else { //oblique (bottom right -> top left) - // ex: -60,0,0,0,4.0,25.0,-12.5,12.5,-6 + // ex: -60, 0,0, 0,4.0, 25.0, -12.5, 12.5, -6 // Base::Console().Message("TRACE - DGH-makeEdgeOverlay - making angle < 0\n"); double xRightAtom = origin.x + ((minY - origin.y)/slope); //x-coord of left end of Atom line double xLeftAtom = origin.x + ((maxY - origin.y)/slope); //x-coord of right end of Atom line @@ -447,9 +443,9 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box // make repeats for (int i = 0; i < repeatTotal; i++) { - Base::Vector3d newStart(leftStartX + float(i)*interval,minY,0); - Base::Vector3d newEnd(leftEndX + float(i)*interval,maxY,0); - TopoDS_Edge newLine = makeLine(newStart,newEnd); + Base::Vector3d newStart(leftStartX + float(i)*interval, minY, 0); + Base::Vector3d newEnd(leftEndX + float(i)*interval, maxY, 0); + TopoDS_Edge newLine = makeLine(newStart, newEnd); result.push_back(newLine); } } @@ -460,11 +456,11 @@ std::vector DrawGeomHatch::makeEdgeOverlay(PATLineSpec hl, Bnd_Box TopoDS_Edge DrawGeomHatch::makeLine(Base::Vector3d s, Base::Vector3d e) { TopoDS_Edge result; - gp_Pnt start(s.x,s.y,0.0); - gp_Pnt end(e.x,e.y,0.0); + gp_Pnt start(s.x, s.y, 0.0); + gp_Pnt end(e.x, e.y, 0.0); TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(start); TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(end); - BRepBuilderAPI_MakeEdge makeEdge1(v1,v2); + BRepBuilderAPI_MakeEdge makeEdge1(v1, v2); result = makeEdge1.Edge(); return result; } @@ -473,7 +469,7 @@ TopoDS_Edge DrawGeomHatch::makeLine(Base::Vector3d s, Base::Vector3d e) //! these will be clipped to shape on the gui side std::vector DrawGeomHatch::getFaceOverlay(int fdx) { -// Base::Console().Message("TRACE - DGH::getFaceOverlay(%d)\n",fdx); +// Base::Console().Message("TRACE - DGH::getFaceOverlay(%d)\n", fdx); std::vector result; DrawViewPart* source = getSourceView(); if (!source || @@ -482,7 +478,7 @@ std::vector DrawGeomHatch::getFaceOverlay(int fdx) return result; } - TopoDS_Face face = extractFace(source,fdx); + TopoDS_Face face = extractFace(source, fdx); Bnd_Box bBox; BRepBndLib::AddOptimal(face, bBox); @@ -496,7 +492,7 @@ std::vector DrawGeomHatch::getFaceOverlay(int fdx) for (auto& e: candidates) { TechDraw::BaseGeomPtr base = BaseGeom::baseFactory(e); if (!base) { - Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n",i); + Base::Console().Log("FAIL - DGH::getFaceOverlay - baseFactory failed for edge: %d\n", i); throw Base::ValueError("DGH::getFaceOverlay - baseFactory failed"); } resultGeoms.push_back(base); @@ -519,9 +515,9 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface ) std::vector faceWires = source->getWireForFace(iface); //build face(s) from geometry - gp_Pnt gOrg(0.0,0.0,0.0); - gp_Dir gDir(0.0,0.0,1.0); - gp_Pln plane(gOrg,gDir); + gp_Pnt gOrg(0.0, 0.0, 0.0); + gp_Dir gDir(0.0, 0.0, 1.0); + gp_Pln plane(gOrg, gDir); BRepBuilderAPI_MakeFace mkFace(plane, faceWires.front(), true); std::vector::iterator itWire = ++faceWires.begin(); //starting with second wire @@ -538,7 +534,7 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface ) try { // mirror about the Y axis gp_Trsf mirrorTransform; - mirrorTransform.SetMirror( gp_Ax2(gp_Pnt(0.0,0.0,0.0), gp_Dir(0, 1, 0)) ); + mirrorTransform.SetMirror( gp_Ax2(gp_Pnt(0.0, 0.0, 0.0), gp_Dir(0, 1, 0)) ); BRepBuilderAPI_Transform mkTrf(face, mirrorTransform); temp = mkTrf.Shape(); } @@ -553,7 +549,7 @@ TopoDS_Face DrawGeomHatch::extractFace(DrawViewPart* source, int iface ) PyObject *DrawGeomHatch::getPyObject() { if (PythonObject.is(Py::_None())) { - PythonObject = Py::Object(new DrawGeomHatchPy(this),true); + PythonObject = Py::Object(new DrawGeomHatchPy(this), true); } return Py::new_reference_to(PythonObject); } @@ -570,7 +566,7 @@ void DrawGeomHatch::replacePatIncluded(std::string newPatFile) } } -void DrawGeomHatch::onDocumentRestored() +void DrawGeomHatch::onDocumentRestored() { // Base::Console().Message("DGH::onDocumentRestored()\n"); if (PatIncluded.isEmpty()) { @@ -636,7 +632,7 @@ std::string DrawGeomHatch::prefGeomHatchName() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT"); std::string defaultNamePattern = "Diamond"; - std::string result = hGrp->GetASCII("NamePattern",defaultNamePattern.c_str()); + std::string result = hGrp->GetASCII("NamePattern", defaultNamePattern.c_str()); if (result.empty()) { result = defaultNamePattern; } @@ -648,7 +644,7 @@ App::Color DrawGeomHatch::prefGeomHatchColor() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); App::Color fcColor; - fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000)); + fcColor.setPackedValue(hGrp->GetUnsigned("GeomHatch", 0x00FF0000)); return fcColor; } diff --git a/src/Mod/TechDraw/App/DrawGeomHatch.h b/src/Mod/TechDraw/App/DrawGeomHatch.h index b05fa0c8bb..567ea333e4 100644 --- a/src/Mod/TechDraw/App/DrawGeomHatch.h +++ b/src/Mod/TechDraw/App/DrawGeomHatch.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawGeomHatch_h_ -#define _TechDraw_DrawGeomHatch_h_ +#ifndef TechDraw_DrawGeomHatch_h_ +#define TechDraw_DrawGeomHatch_h_ #include @@ -54,7 +54,7 @@ class TechDrawExport DrawGeomHatch : public App::DocumentObject public: DrawGeomHatch(); - virtual ~DrawGeomHatch(); + ~DrawGeomHatch() = default; App::PropertyLinkSub Source; //the dvX & face(s) this crosshatch belongs to App::PropertyFile FilePattern; diff --git a/src/Mod/TechDraw/App/DrawHatch.cpp b/src/Mod/TechDraw/App/DrawHatch.cpp index 3dd6995aca..2679ac3efb 100644 --- a/src/Mod/TechDraw/App/DrawHatch.cpp +++ b/src/Mod/TechDraw/App/DrawHatch.cpp @@ -63,16 +63,12 @@ DrawHatch::DrawHatch(void) ADD_PROPERTY_TYPE(Source, (nullptr), vgroup, (App::PropertyType)(App::Prop_None), "The View + Face to be hatched"); Source.setScope(App::LinkScope::Global); ADD_PROPERTY_TYPE(HatchPattern, (prefSvgHatch()), vgroup, App::Prop_None, "The hatch pattern file for this area"); - ADD_PROPERTY_TYPE(SvgIncluded, (""), vgroup,App::Prop_None, + ADD_PROPERTY_TYPE(SvgIncluded, (""), vgroup, App::Prop_None, "Embedded SVG hatch file. System use only."); // n/a to end users std::string svgFilter("SVG files (*.svg *.SVG);;Bitmap files(*.jpg *.jpeg *.png *.bmp);;All files (*)"); HatchPattern.setFilter(svgFilter); } -DrawHatch::~DrawHatch() -{ -} - void DrawHatch::onChanged(const App::Property* prop) { if (!isRestoring()) { @@ -123,12 +119,12 @@ PyObject *DrawHatch::getPyObject(void) { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawHatchPy(this),true); + PythonObject = Py::Object(new DrawHatchPy(this), true); } return Py::new_reference_to(PythonObject); } -bool DrawHatch::faceIsHatched(int i,std::vector hatchObjs) +bool DrawHatch::faceIsHatched(int i, std::vector hatchObjs) { bool result = false; bool found = false; @@ -167,7 +163,7 @@ bool DrawHatch::affectsFace(int i) //remove a subElement(Face) from Source PropertyLinkSub bool DrawHatch::removeSub(std::string toRemove) { -// Base::Console().Message("DH::removeSub(%s)\n",toRemove.c_str()); +// Base::Console().Message("DH::removeSub(%s)\n", toRemove.c_str()); bool removed = false; const std::vector &sourceNames = Source.getSubValues(); std::vector newList; @@ -187,7 +183,7 @@ bool DrawHatch::removeSub(std::string toRemove) bool DrawHatch::removeSub(int i) { -// Base::Console().Message("DH::removeSub(%d)\n",i); +// Base::Console().Message("DH::removeSub(%d)\n", i); std::stringstream ss; ss << "Face" << i; return removeSub(ss.str()); @@ -211,7 +207,7 @@ void DrawHatch::replaceFileIncluded(std::string newSvgFile) } } -void DrawHatch::onDocumentRestored() +void DrawHatch::onDocumentRestored() { //if this is a restore, we should be checking for SvgIncluded empty, // if it is, set it up from hatchPattern, diff --git a/src/Mod/TechDraw/App/DrawHatch.h b/src/Mod/TechDraw/App/DrawHatch.h index ad4fd3fd4e..b1c9cd9cf0 100644 --- a/src/Mod/TechDraw/App/DrawHatch.h +++ b/src/Mod/TechDraw/App/DrawHatch.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawHatch_h_ -#define _TechDraw_DrawHatch_h_ +#ifndef TechDraw_DrawHatch_h_ +#define TechDraw_DrawHatch_h_ #include @@ -44,7 +44,7 @@ class TechDrawExport DrawHatch : public App::DocumentObject public: DrawHatch(); - ~DrawHatch() override; + ~DrawHatch() = default; App::PropertyLinkSub Source; // the dvp & face this hatch belongs to App::PropertyFile HatchPattern; @@ -66,10 +66,10 @@ public: bool removeSub(std::string toRemove); bool removeSub(int i); bool empty(); - static bool faceIsHatched(int i,std::vector hatchObjs); + static bool faceIsHatched(int i, std::vector hatchObjs); static std::string prefSvgHatch(); static App::Color prefSvgHatchColor(); - + bool isSvgHatch() const; bool isBitmapHatch() const; diff --git a/src/Mod/TechDraw/App/DrawLeaderLine.cpp b/src/Mod/TechDraw/App/DrawLeaderLine.cpp index 4cc2f7b0d6..7c224cf22a 100644 --- a/src/Mod/TechDraw/App/DrawLeaderLine.cpp +++ b/src/Mod/TechDraw/App/DrawLeaderLine.cpp @@ -72,42 +72,38 @@ DrawLeaderLine::DrawLeaderLine() { static const char *group = "Leader"; - ADD_PROPERTY_TYPE(LeaderParent,(nullptr),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(LeaderParent, (nullptr), group, (App::PropertyType)(App::Prop_None), "View to which this leader is attached"); LeaderParent.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(WayPoints,(Base::Vector3d()) ,group, App::Prop_None, + ADD_PROPERTY_TYPE(WayPoints, (Base::Vector3d()) ,group, App::Prop_None, "Intermediate points for Leader line"); // EndType.setEnums(ArrowTypeEnums); -// ADD_PROPERTY(EndType,(prefEnd())); +// ADD_PROPERTY(EndType, (prefEnd())); StartSymbol.setEnums(ArrowPropEnum::ArrowTypeEnums); - ADD_PROPERTY(StartSymbol,(0l)); //filled arrow + ADD_PROPERTY(StartSymbol, (0l)); //filled arrow // ADD_PROPERTY_TYPE(StartSymbol, (0), group, App::Prop_None, "Symbol (arrowhead) for start of line"); EndSymbol.setEnums(ArrowPropEnum::ArrowTypeEnums); - ADD_PROPERTY(EndSymbol,(7l)); //no symbol + ADD_PROPERTY(EndSymbol, (7l)); //no symbol // ADD_PROPERTY_TYPE(EndSymbol, (0), group, App::Prop_None, "Symbol (arrowhead) for end of line"); - ADD_PROPERTY_TYPE(Scalable ,(false),group,App::Prop_None,"Scale line with LeaderParent"); - ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()),group,App::Prop_None,"Forces last line segment to be horizontal"); + ADD_PROPERTY_TYPE(Scalable ,(false), group, App::Prop_None, "Scale line with LeaderParent"); + ADD_PROPERTY_TYPE(AutoHorizontal ,(getDefAuto()), group, App::Prop_None, "Forces last line segment to be horizontal"); //hide the DrawView properties that don't apply to Leader - ScaleType.setStatus(App::Property::ReadOnly,true); - ScaleType.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::ReadOnly,true); - Scale.setStatus(App::Property::Hidden,true); - Rotation.setStatus(App::Property::ReadOnly,true); - Rotation.setStatus(App::Property::Hidden,true); - Caption.setStatus(App::Property::Hidden,true); + ScaleType.setStatus(App::Property::ReadOnly, true); + ScaleType.setStatus(App::Property::Hidden, true); + Scale.setStatus(App::Property::ReadOnly, true); + Scale.setStatus(App::Property::Hidden, true); + Rotation.setStatus(App::Property::ReadOnly, true); + Rotation.setStatus(App::Property::Hidden, true); + Caption.setStatus(App::Property::Hidden, true); LockPosition.setValue(true); - LockPosition.setStatus(App::Property::Hidden,true); -} - -DrawLeaderLine::~DrawLeaderLine() -{ + LockPosition.setStatus(App::Property::Hidden, true); } void DrawLeaderLine::onChanged(const App::Property* prop) @@ -142,7 +138,7 @@ App::DocumentObjectExecReturn *DrawLeaderLine::execute() if (!keepUpdated()) { return App::DocumentObject::StdReturn; } - adjustLastSegment(); + adjustLastSegment(); overrideKeepUpdated(false); return DrawView::execute(); } @@ -288,7 +284,7 @@ bool DrawLeaderLine::getDefAuto() const { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/LeaderLines"); - bool result = hGrp->GetBool("AutoHorizontal",true); + bool result = hGrp->GetBool("AutoHorizontal", true); return result; } @@ -297,7 +293,7 @@ PyObject *DrawLeaderLine::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawLeaderLinePy(this),true); + PythonObject = Py::Object(new DrawLeaderLinePy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawLeaderLine.h b/src/Mod/TechDraw/App/DrawLeaderLine.h index 269e60638d..dd56ecc919 100644 --- a/src/Mod/TechDraw/App/DrawLeaderLine.h +++ b/src/Mod/TechDraw/App/DrawLeaderLine.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawLeaderLine_h_ -#define _TechDraw_DrawLeaderLine_h_ +#ifndef TechDraw_DrawLeaderLine_h_ +#define TechDraw_DrawLeaderLine_h_ #include @@ -41,7 +41,7 @@ class TechDrawExport DrawLeaderLine : public TechDraw::DrawView public: DrawLeaderLine(); - ~DrawLeaderLine() override; + ~DrawLeaderLine() = default; App::PropertyLink LeaderParent; App::PropertyVectorList WayPoints; @@ -61,7 +61,7 @@ public: return "TechDrawGui::ViewProviderLeader"; } PyObject *getPyObject() override; - QRectF getRect() const override { return QRectF(0,0,1,1);} + QRectF getRect() const override { return { 0, 0,1, 1}; } Base::Vector3d getAttachPoint(); DrawView* getBaseView() const; diff --git a/src/Mod/TechDraw/App/DrawPage.cpp b/src/Mod/TechDraw/App/DrawPage.cpp index b09f7d5092..ef36bd1fae 100644 --- a/src/Mod/TechDraw/App/DrawPage.cpp +++ b/src/Mod/TechDraw/App/DrawPage.cpp @@ -93,7 +93,7 @@ DrawPage::DrawPage(void) Base::Reference hGrp = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")-> GetGroup("Mod/TechDraw/General"); - double defScale = hGrp->GetFloat("DefaultScale",1.0); + double defScale = hGrp->GetFloat("DefaultScale", 1.0); ADD_PROPERTY_TYPE(Scale, (defScale), group, (App::PropertyType)(App::Prop_None), "Scale factor for this Page"); ADD_PROPERTY_TYPE(NextBalloonIndex, (1), group, (App::PropertyType)(App::Prop_None), @@ -119,7 +119,7 @@ void DrawPage::onChanged(const App::Property* prop) if (!isRestoring() && !isUnsetting()) { //would be nice if this message was displayed immediately instead of after the recomputeFeature - Base::Console().Message("Rebuilding Views for: %s/%s\n",getNameInDocument(),Label.getValue()); + Base::Console().Message("Rebuilding Views for: %s/%s\n", getNameInDocument(), Label.getValue()); updateAllViews(); purgeTouched(); } @@ -156,7 +156,7 @@ void DrawPage::onChanged(const App::Property* prop) // TODO: Also update Template graphic. } - App::DocumentObject::onChanged(prop); + App::DocumentObject::onChanged(prop); } //Page is just a container. It doesn't "do" anything. @@ -165,7 +165,7 @@ App::DocumentObjectExecReturn *DrawPage::execute(void) return App::DocumentObject::execute(); } -// this is now irrelevant, b/c DP::execute doesn't do anything. +// this is now irrelevant, b/c DP::execute doesn't do anything. short DrawPage::mustExecute() const { short result = 0; @@ -185,7 +185,7 @@ PyObject *DrawPage::getPyObject(void) { if (PythonObject.is(Py::_None())){ // ref counter is set to 1 - PythonObject = Py::Object(new DrawPagePy(this),true); + PythonObject = Py::Object(new DrawPagePy(this), true); } return Py::new_reference_to(PythonObject); @@ -271,7 +271,7 @@ int DrawPage::addView(App::DocumentObject *docObj) //check if View fits on Page if ( !view->checkFit(this) ) { - Base::Console().Warning("%s is larger than page. Will be scaled.\n",view->getNameInDocument()); + Base::Console().Warning("%s is larger than page. Will be scaled.\n", view->getNameInDocument()); view->ScaleType.setValue("Automatic"); } @@ -365,7 +365,7 @@ void DrawPage::updateAllViews() } } -std::vector DrawPage::getAllViews(void) +std::vector DrawPage::getAllViews(void) { auto views = Views.getValues(); //list of docObjects std::vector allViews; @@ -375,7 +375,7 @@ std::vector DrawPage::getAllViews(void) TechDraw::DrawProjGroup* dpg = static_cast(v); if (dpg) { //can't really happen! std::vector pgViews = dpg->Views.getValues(); - allViews.insert(allViews.end(),pgViews.begin(),pgViews.end()); + allViews.insert(allViews.end(), pgViews.begin(), pgViews.end()); } } } @@ -407,7 +407,7 @@ void DrawPage::unsetupObject() } std::vector emptyViews; //probably superfluous Views.setValues(emptyViews); - + } catch (...) { Base::Console().Warning("DP::unsetupObject - %s - error while deleting children\n", getNameInDocument()); @@ -431,11 +431,11 @@ int DrawPage::getNextBalloonIndex(void) } void DrawPage::handleChangedPropertyType( - Base::XMLReader &reader, const char * TypeName, App::Property * prop) + Base::XMLReader &reader, const char * TypeName, App::Property * prop) { if (prop == &Scale) { App::PropertyFloat tmp; - if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float tmp.setContainer(this); tmp.Restore(reader); double tmpValue = tmp.getValue(); @@ -445,7 +445,7 @@ void DrawPage::handleChangedPropertyType( Scale.setValue(1.0); } } else { - // has Scale prop that isn't Float! + // has Scale prop that isn't Float! Base::Console().Log("DrawPage::Restore - old Document Scale is Not Float!\n"); // no idea } @@ -471,7 +471,7 @@ bool DrawPage::GlobalUpdateDrawings(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - bool result = hGrp->GetBool("GlobalUpdateDrawings", true); + bool result = hGrp->GetBool("GlobalUpdateDrawings", true); return result; } @@ -480,7 +480,7 @@ bool DrawPage::AllowPageOverride(void) { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - bool result = hGrp->GetBool("AllowPageOverride", true); + bool result = hGrp->GetBool("AllowPageOverride", true); return result; } diff --git a/src/Mod/TechDraw/App/DrawPage.h b/src/Mod/TechDraw/App/DrawPage.h index bfff9156c8..cc49ef77e2 100644 --- a/src/Mod/TechDraw/App/DrawPage.h +++ b/src/Mod/TechDraw/App/DrawPage.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawPage_h_ -#define _DrawPage_h_ +#ifndef DrawPage_h_ +#define DrawPage_h_ #include @@ -50,7 +50,7 @@ public: App::PropertyFloatConstraint Scale; App::PropertyEnumeration ProjectionType; // First or Third Angle - + App::PropertyInteger NextBalloonIndex; /** @name methods override Feature */ @@ -94,10 +94,10 @@ public: bool isUnsetting() { return nowUnsetting; } void requestPaint(); std::vector getAllViews() ; - DrawViewPart *balloonParent; //could be many balloons on page? - + DrawViewPart *balloonParent; //could be many balloons on page? + int getNextBalloonIndex(); - + void updateAllViews(); static bool GlobalUpdateDrawings(); static bool AllowPageOverride(); diff --git a/src/Mod/TechDraw/App/DrawPagePyImp.cpp b/src/Mod/TechDraw/App/DrawPagePyImp.cpp index 20798c73bf..153240d86d 100644 --- a/src/Mod/TechDraw/App/DrawPagePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawPagePyImp.cpp @@ -29,7 +29,7 @@ std::string DrawPagePy::representation() const PyObject* DrawPagePy::addView(PyObject* args) { //this implements iRC = pyPage.addView(pyView) -or- - //doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + //doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { @@ -50,7 +50,7 @@ PyObject* DrawPagePy::addView(PyObject* args) PyObject* DrawPagePy::removeView(PyObject* args) { //this implements iRC = pyPage.removeView(pyView) -or- - //doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + //doCommand(Doc, "App.activeDocument().%s.removeView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { diff --git a/src/Mod/TechDraw/App/DrawParametricTemplate.cpp b/src/Mod/TechDraw/App/DrawParametricTemplate.cpp index 00728cecef..dabae70dce 100644 --- a/src/Mod/TechDraw/App/DrawParametricTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawParametricTemplate.cpp @@ -51,7 +51,7 @@ PROPERTY_SOURCE(TechDraw::DrawParametricTemplate, TechDraw::DrawTemplate) DrawParametricTemplate::DrawParametricTemplate() { static const char *group = "Page"; - ADD_PROPERTY_TYPE(Template ,(""),group, (App::PropertyType) App::Prop_None,"Template script"); + ADD_PROPERTY_TYPE(Template ,(""), group, (App::PropertyType) App::Prop_None, "Template script"); } DrawParametricTemplate::~DrawParametricTemplate() @@ -63,7 +63,7 @@ PyObject *DrawParametricTemplate::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawParametricTemplatePy(this),true); + PythonObject = Py::Object(new DrawParametricTemplatePy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawParametricTemplate.h b/src/Mod/TechDraw/App/DrawParametricTemplate.h index 5000b78ea5..c38604599c 100644 --- a/src/Mod/TechDraw/App/DrawParametricTemplate.h +++ b/src/Mod/TechDraw/App/DrawParametricTemplate.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_DrawParametricTemplate_h_ -#define _TECHDRAW_DrawParametricTemplate_h_ +#ifndef TECHDRAW_DrawParametricTemplate_h_ +#define TECHDRAW_DrawParametricTemplate_h_ #include diff --git a/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp index b4b175509b..1aed442715 100644 --- a/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawParametricTemplatePyImp.cpp @@ -74,7 +74,7 @@ PyObject* DrawParametricTemplatePy::drawLine(PyObject *args) if (!PyArg_ParseTuple(args, "dddd", &x1, &y1, &x2, &y2)) return nullptr; - getDrawParametricTemplatePtr()->drawLine(x1,y1,x2,y2); + getDrawParametricTemplatePtr()->drawLine(x1, y1, x2, y2); Py_Return; diff --git a/src/Mod/TechDraw/App/DrawProjGroup.cpp b/src/Mod/TechDraw/App/DrawProjGroup.cpp index f74ffd80aa..3ba29d67cc 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroup.cpp @@ -69,12 +69,12 @@ DrawProjGroup::DrawProjGroup() Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - bool autoDist = hGrp->GetBool("AutoDist",true); + bool autoDist = hGrp->GetBool("AutoDist", true); ADD_PROPERTY_TYPE(Source, (nullptr), group, App::Prop_None, "Shape to view"); Source.setScope(App::LinkScope::Global); Source.setAllowExternal(true); - ADD_PROPERTY_TYPE(XSource, (nullptr), group,App::Prop_None, "External 3D Shape to view"); + ADD_PROPERTY_TYPE(XSource, (nullptr), group, App::Prop_None, "External 3D Shape to view"); ADD_PROPERTY_TYPE(Anchor, (nullptr), group, App::Prop_None, "The root view to align projections with"); Anchor.setScope(App::LinkScope::Global); @@ -91,10 +91,6 @@ DrawProjGroup::DrawProjGroup() Caption.setStatus(App::Property::Hidden, true); } -DrawProjGroup::~DrawProjGroup() -{ -} - //TODO: this duplicates code in DVP std::vector DrawProjGroup::getAllSources() const { @@ -165,7 +161,7 @@ void DrawProjGroup::onChanged(const App::Property* prop) // } if (prop == &Rotation) { - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { Rotation.setValue(0.0); purgeTouched(); Base::Console().Log("DPG: Projection Groups do not rotate. Change ignored.\n"); @@ -312,7 +308,7 @@ double DrawProjGroup::autoScale(double w, double h) const double xScale = w / bigBox.width(); // > 1 page bigger than figure double yScale = h / bigBox.height(); // < 1 page is smaller than figure - double newScale = std::min(xScale,yScale); + double newScale = std::min(xScale, yScale); return DrawUtil::sensibleScale(newScale); } @@ -325,7 +321,7 @@ QRectF DrawProjGroup::getRect() const QRectF DrawProjGroup::getRect(bool scaled) const { // Base::Console().Message("DPG::getRect - views: %d\n", Views.getValues().size()); - DrawProjGroupItem *viewPtrs[10]; + std::array viewPtrs; arrangeViewPointers(viewPtrs); double totalWidth, totalHeight; getViewArea(viewPtrs, totalWidth, totalHeight, scaled); @@ -337,19 +333,19 @@ QRectF DrawProjGroup::getRect(bool scaled) const rectW *= fudge; rectH *= fudge; - return QRectF(0,0,rectW,rectH); + return { 0, 0, rectW, rectH }; } //find area consumed by Views only - scaled or unscaled -void DrawProjGroup::getViewArea(DrawProjGroupItem *viewPtrs[10], +void DrawProjGroup::getViewArea(std::array& viewPtrs, double &width, double &height, bool scaled) const { // Get the child view bounding boxes - Base::BoundBox3d bboxes[10]; + std::array bboxes; makeViewBbs(viewPtrs, bboxes, scaled); - //TODO: note that TLF/TRF/BLF,BRF extend a bit farther than a strict row/col arrangement would suggest. + //TODO: note that TLF/TRF/BLF, BRF extend a bit farther than a strict row/col arrangement would suggest. //get widest view in each row/column double col0w = std::max(std::max(bboxes[0].LengthX(), bboxes[3].LengthX()), bboxes[7].LengthX()), col1w = std::max(std::max(bboxes[1].LengthX(), bboxes[4].LengthX()), bboxes[8].LengthX()), @@ -371,7 +367,7 @@ App::DocumentObject * DrawProjGroup::getProjObj(const char *viewProjType) const if (!projPtr) { //if an element in Views is not a DPGI, something really bad has happened somewhere Base::Console().Log("PROBLEM - DPG::getProjObj - non DPGI entry in Views! %s / %s\n", - getNameInDocument(),viewProjType); + getNameInDocument(), viewProjType); throw Base::TypeError("Error: projection in DPG list is not a DPGI!"); } else if(strcmp(viewProjType, projPtr->Type.getValueAsString()) == 0 ) { return it; @@ -388,7 +384,7 @@ DrawProjGroupItem* DrawProjGroup::getProjItem(const char *viewProjType) const if (!result && docObj) { //should never have a item in DPG that is not a DPGI. Base::Console().Log("PROBLEM - DPG::getProjItem finds non-DPGI in Group %s / %s\n", - getNameInDocument(),viewProjType); + getNameInDocument(), viewProjType); throw Base::TypeError("Error: projection in DPG list is not a DPGI!"); } return result; @@ -421,7 +417,7 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const if (!view) { //should never have a item in DPG that is not a DPGI. Base::Console().Log("PROBLEM - DPG::hasProjection finds non-DPGI in Group %s / %s\n", - getNameInDocument(),viewProjType); + getNameInDocument(), viewProjType); throw Base::TypeError("Error: projection in DPG list is not a DPGI!"); } @@ -435,11 +431,11 @@ bool DrawProjGroup::hasProjection(const char *viewProjType) const App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) { DrawProjGroupItem *view( nullptr ); - std::pair vecs; + std::pair vecs; DrawPage* dp = findParentPage(); if (!dp) - Base::Console().Error("DPG:addProjection - %s - DPG is not on a page!\n",getNameInDocument()); + Base::Console().Error("DPG:addProjection - %s - DPG is not on a page!\n", getNameInDocument()); if ( checkViewProjType(viewProjType) && !hasProjection(viewProjType) ) { std::string FeatName = getDocument()->getUniqueObjectName("ProjItem"); @@ -449,7 +445,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) if (!view && docObj) { //should never happen that we create a DPGI that isn't a DPGI!! Base::Console().Log("PROBLEM - DPG::addProjection - created a non DPGI! %s / %s\n", - getNameInDocument(),viewProjType); + getNameInDocument(), viewProjType); throw Base::TypeError("Error: new projection is not a DPGI!"); } if (view) { //coverity CID 151722 @@ -474,7 +470,7 @@ App::DocumentObject * DrawProjGroup::addProjection(const char *viewProjType) Anchor.purgeTouched(); requestPaint(); //make sure the group object is on the Gui page view->LockPosition.setValue(true); //lock "Front" position within DPG (note not Page!). - view->LockPosition.setStatus(App::Property::ReadOnly,true); //Front should stay locked. + view->LockPosition.setStatus(App::Property::ReadOnly, true); //Front should stay locked. view->LockPosition.purgeTouched(); } // addView(view); //from DrawViewCollection @@ -507,7 +503,7 @@ int DrawProjGroup::removeProjection(const char *viewProjType) } else { //if an element in Views is not a DPGI, something really bad has happened somewhere Base::Console().Log("PROBLEM - DPG::removeProjection - tries to remove non DPGI! %s / %s\n", - getNameInDocument(),viewProjType); + getNameInDocument(), viewProjType); throw Base::TypeError("Error: projection in DPG list is not a DPGI!"); } } @@ -542,31 +538,31 @@ int DrawProjGroup::purgeProjections() return Views.getValues().size(); } -std::pair DrawProjGroup::getDirsFromFront(DrawProjGroupItem* view) +std::pair DrawProjGroup::getDirsFromFront(DrawProjGroupItem* view) { - std::pair result; + std::pair result; std::string viewType = view->Type.getValueAsString(); result = getDirsFromFront(viewType); return result; } -std::pair DrawProjGroup::getDirsFromFront(std::string viewType) +std::pair DrawProjGroup::getDirsFromFront(std::string viewType) { // Base::Console().Message("DPG::getDirsFromFront(%s)\n", viewType.c_str()); - std::pair result; + std::pair result; Base::Vector3d projDir, rotVec; DrawProjGroupItem* anch = getAnchor(); if (!anch) { - Base::Console().Warning("DPG::getDirsFromFront - %s - No Anchor!\n",Label.getValue()); + Base::Console().Warning("DPG::getDirsFromFront - %s - No Anchor!\n", Label.getValue()); throw Base::RuntimeError("Project Group missing Anchor projection item"); } Base::Vector3d dirAnch = anch->Direction.getValue(); Base::Vector3d rotAnch = anch->getXDirection(); - result = std::make_pair(dirAnch,rotAnch); + result = std::make_pair(dirAnch, rotAnch); - Base::Vector3d org(0.0,0.0,0.0); + Base::Vector3d org(0.0, 0.0, 0.0); gp_Ax2 anchorCS = anch->getProjectionCS(org); gp_Pnt gOrg(0.0, 0.0, 0.0); gp_Dir gDir = anchorCS.Direction(); @@ -629,11 +625,11 @@ std::pair DrawProjGroup::getDirsFromFront(std::st gp_Vec(gDir)); rotVec = dir2vec(newXDir); } else { - Base::Console().Error("DrawProjGroup - %s unknown projection: %s\n",getNameInDocument(),viewType.c_str()); + Base::Console().Error("DrawProjGroup - %s unknown projection: %s\n", getNameInDocument(), viewType.c_str()); return result; } - result = std::make_pair(projDir,rotVec); + result = std::make_pair(projDir, rotVec); return result; } @@ -656,15 +652,15 @@ gp_Dir DrawProjGroup::vec2dir(Base::Vector3d v) //this can be improved. this implementation positions views too far apart. Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr) { -// Base::Console().Message("DPG::getXYPosition(%s)\n",Label.getValue()); +// Base::Console().Message("DPG::getXYPosition(%s)\n", Label.getValue()); - Base::Vector3d result(0.0,0.0,0.0); - //Front view position is always (0,0) + Base::Vector3d result(0.0, 0.0, 0.0); + //Front view position is always (0, 0) if (strcmp(viewTypeCStr, "Front") == 0 ) { // Front! return result; } - const int idxCount = 10; - DrawProjGroupItem *viewPtrs[idxCount]; + const int idxCount = MAXPROJECTIONCOUNT; + std::array viewPtrs; arrangeViewPointers(viewPtrs); int viewIndex = getViewIndex(viewTypeCStr); @@ -681,7 +677,7 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr) std::vector position(idxCount); // Calculate bounding boxes for each displayed view - Base::BoundBox3d bboxes[10]; + std::array bboxes; makeViewBbs(viewPtrs, bboxes); //scaled double xSpacing = spacingX.getValue(); //in mm, no scale @@ -706,7 +702,7 @@ Base::Vector3d DrawProjGroup::getXYPosition(const char *viewTypeCStr) //if we have iso's, make sure they fit the grid. if (viewPtrs[0] || viewPtrs[2] || viewPtrs[7] || viewPtrs[9]) { - bigCol = std::max(bigCol,bigRow); + bigCol = std::max(bigCol, bigRow); bigRow = bigCol; } @@ -851,9 +847,9 @@ int DrawProjGroup::getViewIndex(const char *viewTypeCStr) const return result; } -void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const +void DrawProjGroup::arrangeViewPointers(std::array &viewPtrs) const { - for (int i=0; i<10; ++i) { + for (int i=0; i < MAXPROJECTIONCOUNT; ++i) { viewPtrs[i] = nullptr; } @@ -919,23 +915,23 @@ void DrawProjGroup::arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const viewPtrs[thirdAngle ? 9 : 0] = oView; } else { Base::Console().Warning("DPG: %s - unknown view type: %s. \n", - getNameInDocument(),viewTypeCStr); + getNameInDocument(), viewTypeCStr); throw Base::TypeError("Unknown view type in DrawProjGroup::arrangeViewPointers."); } } } } else { - Base::Console().Warning("DPG: %s - unknown Projection convention: %s\n",getNameInDocument(),projType); + Base::Console().Warning("DPG: %s - unknown Projection convention: %s\n", getNameInDocument(), projType); throw Base::ValueError("Unknown Projection convention in DrawProjGroup::arrangeViewPointers"); } } -void DrawProjGroup::makeViewBbs(DrawProjGroupItem *viewPtrs[10], - Base::BoundBox3d bboxes[10], +void DrawProjGroup::makeViewBbs(std::array &viewPtrs, + std::array &bboxes, bool scaled) const { Base::BoundBox3d empty(Base::Vector3d(0.0, 0.0, 0.0), 0.0); - for (int i = 0; i < 10; ++i) { + for (int i = 0; i < MAXPROJECTIONCOUNT; ++i) { bboxes[i] = empty; if (viewPtrs[i]) { bboxes[i] = viewPtrs[i]->getBoundingBox(); @@ -1119,11 +1115,11 @@ void DrawProjGroup::updateSecondaryDirs() Base::Vector3d anchDir = anchor->Direction.getValue(); Base::Vector3d anchRot = anchor->getXDirection(); - std::map > saveVals; + std::map > saveVals; std::string key; std::pair data; for (auto& docObj: Views.getValues()) { - std::pair newDirs; + std::pair newDirs; std::string pic; DrawProjGroupItem* v = static_cast(docObj); ProjItemType t = static_cast(v->Type.getValue()); @@ -1199,7 +1195,7 @@ void DrawProjGroup::updateSecondaryDirs() } void DrawProjGroup::rotate(const std::string &rotationdirection) { - std::pair newDirs; + std::pair newDirs; if(rotationdirection == "Right") newDirs = getDirsFromFront("Left"); // Front -> Right -> Rear -> Left -> Front else if(rotationdirection == "Left") newDirs = getDirsFromFront("Right"); // Front -> Left -> Rear -> Right -> Front else if(rotationdirection == "Up") newDirs = getDirsFromFront("Bottom"); // Front -> Top -> Rear -> Bottom -> Front @@ -1219,10 +1215,10 @@ void DrawProjGroup::spin(const std::string &spindirection) if(spindirection == "CCW") angle = - M_PI / 2.0; // Top -> Left -> Bottom -> Right -> Top DrawProjGroupItem* anchor = getAnchor(); - Base::Vector3d org(0.0,0.0,0.0); + Base::Vector3d org(0.0, 0.0, 0.0); Base::Vector3d curRot = anchor->getXDirection(); Base::Vector3d curDir = anchor->Direction.getValue(); - Base::Vector3d newRot = DrawUtil::vecRotate(curRot,angle,curDir,org); + Base::Vector3d newRot = DrawUtil::vecRotate(curRot, angle, curDir, org); anchor->XDirection.setValue(newRot); updateSecondaryDirs(); @@ -1259,7 +1255,7 @@ void DrawProjGroup::dumpISO(const char * title) axis = v->getXDirection(); Base::Console().Message("%s: %s/%s\n", - t.c_str(),DrawUtil::formatVector(dir).c_str(),DrawUtil::formatVector(axis).c_str()); + t.c_str(), DrawUtil::formatVector(dir).c_str(), DrawUtil::formatVector(axis).c_str()); } } @@ -1267,7 +1263,7 @@ PyObject *DrawProjGroup::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawProjGroupPy(this),true); + PythonObject = Py::Object(new DrawProjGroupPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawProjGroup.h b/src/Mod/TechDraw/App/DrawProjGroup.h index 7f738f4e8a..e2654667ce 100644 --- a/src/Mod/TechDraw/App/DrawProjGroup.h +++ b/src/Mod/TechDraw/App/DrawProjGroup.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_FEATUREVIEWGROUP_H_ -#define _TECHDRAW_FEATUREVIEWGROUP_H_ +#ifndef TECHDRAW_FEATUREVIEWGROUP_H_ +#define TECHDRAW_FEATUREVIEWGROUP_H_ #include @@ -41,6 +41,7 @@ class gp_Pnt; namespace TechDraw { +const int MAXPROJECTIONCOUNT = 10; class DrawProjGroupItem; @@ -55,7 +56,7 @@ class TechDrawExport DrawProjGroup : public TechDraw::DrawViewCollection public: /// Constructor DrawProjGroup(); - ~DrawProjGroup() override; + ~DrawProjGroup() = default; App::PropertyLinkList Source; App::PropertyXLinkList XSource; @@ -156,15 +157,15 @@ protected: */ bool checkViewProjType(const char *in); - void arrangeViewPointers(DrawProjGroupItem *viewPtrs[10]) const; + void arrangeViewPointers(std::array& viewPtrs) const; /// Populates array of 10 BoundBox3d's given DrawProjGroupItem *s /*! * If documentScale is set, then returned bounding boxes are scaled as in * the Drawing. Otherwise, the dimensions are as in object space. */ - void makeViewBbs(DrawProjGroupItem *viewPtrs[10], - Base::BoundBox3d bboxes[10], + void makeViewBbs(std::array& viewPtrs, + std::array& bboxes, bool scaled = true) const; /// Helper for calculateAutomaticScale @@ -172,7 +173,7 @@ protected: * Returns a width and height in object-space scale, for the enabled views * without accounting for their actual X and Y positions or borders. */ - void getViewArea(DrawProjGroupItem *viewPtrs[10], + void getViewArea(std::array& viewPtrs, double &width, double &height, bool scaled = true) const; @@ -192,4 +193,4 @@ protected: } //namespace TechDraw -#endif // _TECHDRAW_FEATUREVIEWGROUP_H_ +#endif // TECHDRAW_FEATUREVIEWGROUP_H_ diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp index e681d357f7..929744d3c8 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.cpp +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.cpp @@ -64,19 +64,15 @@ DrawProjGroupItem::DrawProjGroupItem(void) { Type.setEnums(TypeEnums); ADD_PROPERTY(Type, ((long)0)); - ADD_PROPERTY_TYPE(RotationVector ,(1.0,0.0,0.0) ,"Base", - App::Prop_None,"Deprecated. Use XDirection."); + ADD_PROPERTY_TYPE(RotationVector ,(1.0, 0.0, 0.0) ,"Base", + App::Prop_None, "Deprecated. Use XDirection."); //projection group controls these -// Direction.setStatus(App::Property::ReadOnly,true); - RotationVector.setStatus(App::Property::ReadOnly,true); //Use XDirection +// Direction.setStatus(App::Property::ReadOnly, true); + RotationVector.setStatus(App::Property::ReadOnly, true); //Use XDirection ScaleType.setValue("Custom"); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); -} - -DrawProjGroupItem::~DrawProjGroupItem() -{ + Scale.setStatus(App::Property::Hidden, true); + ScaleType.setStatus(App::Property::Hidden, true); } short DrawProjGroupItem::mustExecute() const @@ -115,9 +111,9 @@ bool DrawProjGroupItem::showLock(void) const } if (isAnchor() && //don't show lock for Front if DPG is not locked - !parentLock) { + !parentLock) { result = false; - } + } return result; } @@ -164,7 +160,7 @@ void DrawProjGroupItem::postHlrTasks(void) void DrawProjGroupItem::autoPosition() { -// Base::Console().Message("DPGI::autoPosition(%s)\n",Label.getValue()); +// Base::Console().Message("DPGI::autoPosition(%s)\n", Label.getValue()); if (LockPosition.getValue()) { return; } @@ -175,7 +171,7 @@ void DrawProjGroupItem::autoPosition() Y.setValue(newPos.y); requestPaint(); purgeTouched(); //prevents "still touched after recompute" message - getPGroup()->purgeTouched(); //changing dpgi x,y marks parent dpg as touched + getPGroup()->purgeTouched(); //changing dpgi x, y marks parent dpg as touched } } @@ -212,7 +208,7 @@ bool DrawProjGroupItem::isAnchor(void) const /// get a coord system aligned with Direction and Rotation Vector gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt, - const Base::Vector3d& axis, + const Base::Vector3d& axis, const bool flip) const { Base::Console().Message("DPGI::getViewAxis - deprecated. use getProjectionCS\n"); @@ -222,23 +218,23 @@ gp_Ax2 DrawProjGroupItem::getViewAxis(const Base::Vector3d& pt, Base::Vector3d rotVec = getXDirection(); // mirror projDir through XZ plane - Base::Vector3d yNorm(0.0,1.0,0.0); + Base::Vector3d yNorm(0.0, 1.0, 0.0); projDir = projDir - (yNorm * 2.0) * (projDir.Dot(yNorm)); rotVec = rotVec - (yNorm * 2.0) * (rotVec.Dot(yNorm)); - if (DrawUtil::checkParallel(projDir,rotVec)) { + if (DrawUtil::checkParallel(projDir, rotVec)) { Base::Console().Warning("DPGI::getVA - %s - Direction and XDirection parallel. using defaults\n", getNameInDocument()); } try { - viewAxis = gp_Ax2(gp_Pnt(pt.x,pt.y,pt.z), + viewAxis = gp_Ax2(gp_Pnt(pt.x, pt.y, pt.z), gp_Dir(projDir.x, projDir.y, projDir.z), gp_Dir(rotVec.x, rotVec.y, rotVec.z)); } catch (Standard_Failure& e4) { Base::Console().Message("PROBLEM - DPGI (%s) failed to create viewAxis: %s **\n", - getNameInDocument(),e4.GetMessageString()); - return TechDraw::getViewAxis(pt,axis,false); + getNameInDocument(), e4.GetMessageString()); + return TechDraw::getViewAxis(pt, axis, false); } return viewAxis; @@ -266,7 +262,7 @@ Base::Vector3d DrawProjGroupItem::getXDirection(void) const prop = getPropertyByName("RotationVector"); if (prop) { result = RotationVector.getValue(); - + } else { Base::Console().Message("DPGI::getXDirection - missing RotationVector and XDirection\n"); } @@ -313,11 +309,11 @@ double DrawProjGroupItem::getRotateAngle() nx.Normalize(); Base::Vector3d na = Direction.getValue(); na.Normalize(); - Base::Vector3d org(0.0,0.0,0.0); + Base::Vector3d org(0.0, 0.0, 0.0); viewAxis = getProjectionCS(org); gp_Dir gxDir = viewAxis.XDirection(); - Base::Vector3d origX(gxDir.X(),gxDir.Y(),gxDir.Z()); + Base::Vector3d origX(gxDir.X(), gxDir.Y(), gxDir.Z()); origX.Normalize(); double angle = origX.GetAngle(nx); @@ -335,7 +331,7 @@ double DrawProjGroupItem::getScale(void) const if (pgroup) { result = pgroup->getScale(); if (!(result > 0.0)) { - Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue()); + Base::Console().Log("DPGI - %s - bad scale found (%.3f) using 1.0\n", getNameInDocument(), Scale.getValue()); result = 1.0; //kludgy protective fix. autoscale sometimes serves up 0.0! } } @@ -357,7 +353,7 @@ void DrawProjGroupItem::unsetupObject() if ( getPGroup()->getAnchor() == this && !getPGroup()->isUnsetting() ) { Base::Console().Warning("Warning - DPG (%s/%s) may be corrupt - Anchor deleted\n", - getPGroup()->getNameInDocument(),getPGroup()->Label.getValue()); + getPGroup()->getNameInDocument(), getPGroup()->Label.getValue()); getPGroup()->Anchor.setValue(nullptr); //this catches situation where DPGI is deleted w/o DPG::removeProjection } @@ -400,7 +396,7 @@ PyObject *DrawProjGroupItem::getPyObject(void) { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawProjGroupItemPy(this),true); + PythonObject = Py::Object(new DrawProjGroupItemPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawProjGroupItem.h b/src/Mod/TechDraw/App/DrawProjGroupItem.h index 390fb979c4..c0ec0b98c4 100644 --- a/src/Mod/TechDraw/App/DrawProjGroupItem.h +++ b/src/Mod/TechDraw/App/DrawProjGroupItem.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawProjGroupItem_h_ -#define _DrawProjGroupItem_h_ +#ifndef DrawProjGroupItem_h_ +#define DrawProjGroupItem_h_ #include @@ -57,7 +57,7 @@ class TechDrawExport DrawProjGroupItem : public TechDraw::DrawViewPart public: /// Constructor DrawProjGroupItem(); - ~DrawProjGroupItem() override; + ~DrawProjGroupItem() = default; App::PropertyEnumeration Type; App::PropertyVector RotationVector; //this is superseded by dvp xdirection @@ -93,7 +93,8 @@ public: //DPGI always fits on page since DPG handles scaling bool checkFit() const override { return true; } - bool checkFit(DrawPage*) const override { return true; } + bool checkFit(DrawPage* page) const override { (void) page; //avoid unused variable warning + return true; } int countParentPages() const override; DrawPage* findParentPage() const override; diff --git a/src/Mod/TechDraw/App/DrawProjectSplit.cpp b/src/Mod/TechDraw/App/DrawProjectSplit.cpp index e5a78a7942..d661412f8a 100644 --- a/src/Mod/TechDraw/App/DrawProjectSplit.cpp +++ b/src/Mod/TechDraw/App/DrawProjectSplit.cpp @@ -111,13 +111,13 @@ std::vector DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape, BRepBuilderAPI_Copy BuilderCopy(shape); TopoDS_Shape copyShape = BuilderCopy.Shape(); - gp_Pnt inputCenter(0,0,0); + gp_Pnt inputCenter(0, 0,0); TopoDS_Shape scaledShape; scaledShape = TechDraw::scaleShape(copyShape, scale); -// gp_Ax2 viewAxis = TechDraw::getViewAxis(Base::Vector3d(0.0,0.0,0.0),direction); - gp_Ax2 viewAxis = TechDraw::legacyViewAxis1(Base::Vector3d(0.0,0.0,0.0),direction); - TechDraw::GeometryObject* go = buildGeometryObject(scaledShape,viewAxis); +// gp_Ax2 viewAxis = TechDraw::getViewAxis(Base::Vector3d(0.0, 0.0, 0.0), direction); + gp_Ax2 viewAxis = TechDraw::legacyViewAxis1(Base::Vector3d(0.0, 0.0, 0.0), direction); + TechDraw::GeometryObject* go = buildGeometryObject(scaledShape, viewAxis); result = getEdges(go); delete go; @@ -128,7 +128,7 @@ std::vector DrawProjectSplit::getEdgesForWalker(TopoDS_Shape shape, TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape shape, const gp_Ax2& viewAxis) { - TechDraw::GeometryObject* geometryObject = new TechDraw::GeometryObject("DrawProjectSplit",nullptr); + TechDraw::GeometryObject* geometryObject = new TechDraw::GeometryObject("DrawProjectSplit", nullptr); if (geometryObject->usePolygonHLR()){ geometryObject->projectShapeWithPolygonAlgo(shape, @@ -138,7 +138,7 @@ TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape sha geometryObject->projectShape(shape, viewAxis); } - + geometryObject->extractGeometry(TechDraw::ecHARD, //always show the hard&outline visible lines true); geometryObject->extractGeometry(TechDraw::ecOUTLINE, @@ -149,7 +149,7 @@ TechDraw::GeometryObject* DrawProjectSplit::buildGeometryObject(TopoDS_Shape sha //! get the projected edges with all their new intersections. std::vector DrawProjectSplit::getEdges(TechDraw::GeometryObject* geometryObject) { - const std::vector& goEdges = geometryObject->getVisibleFaceEdges(true,true); + const std::vector& goEdges = geometryObject->getVisibleFaceEdges(true, true); std::vector::const_iterator itEdge = goEdges.begin(); std::vector origEdges; for (;itEdge != goEdges.end(); itEdge++) { @@ -184,12 +184,12 @@ std::vector DrawProjectSplit::getEdges(TechDraw::GeometryObject* ge continue; } if (DrawUtil::isZeroEdge(*itOuter)) { - Base::Console().Message("DPS::extractFaces - outerEdge: %d is ZeroEdge\n",iOuter); //this is not finding ZeroEdges + Base::Console().Message("DPS::extractFaces - outerEdge: %d is ZeroEdge\n", iOuter); //this is not finding ZeroEdges continue; //skip zero length edges. shouldn't happen ;) } int iInner = 0; std::vector::iterator itInner = faceEdges.begin(); - for (; itInner != faceEdges.end(); ++itInner,iInner++) { + for (; itInner != faceEdges.end(); ++itInner, iInner++) { if (iInner == iOuter) { continue; } @@ -209,29 +209,29 @@ std::vector DrawProjectSplit::getEdges(TechDraw::GeometryObject* ge } double param = -1; - if (isOnEdge((*itInner),v1,param,false)) { + if (isOnEdge((*itInner), v1, param, false)) { gp_Pnt pnt1 = BRep_Tool::Pnt(v1); splitPoint s1; s1.i = iInner; - s1.v = Base::Vector3d(pnt1.X(),pnt1.Y(),pnt1.Z()); + s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z()); s1.param = param; splits.push_back(s1); } - if (isOnEdge((*itInner),v2,param,false)) { + if (isOnEdge((*itInner), v2, param, false)) { gp_Pnt pnt2 = BRep_Tool::Pnt(v2); splitPoint s2; s2.i = iInner; - s2.v = Base::Vector3d(pnt2.X(),pnt2.Y(),pnt2.Z()); + s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z()); s2.param = param; splits.push_back(s2); } } //inner loop } //outer loop - std::vector sorted = sortSplits(splits,true); + std::vector sorted = sortSplits(splits, true); auto last = std::unique(sorted.begin(), sorted.end(), DrawProjectSplit::splitEqual); //duplicates to back sorted.erase(last, sorted.end()); //remove dupls - std::vector newEdges = splitEdges(faceEdges,sorted); + std::vector newEdges = splitEdges(faceEdges, sorted); if (newEdges.empty()) { Base::Console().Log("LOG - DPS::extractFaces - no newEdges\n"); @@ -262,9 +262,9 @@ bool DrawProjectSplit::isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, b } } if (!outOfBox) { - double dist = DrawUtil::simpleMinDist(v,e); + double dist = DrawUtil::simpleMinDist(v, e); if (dist < 0.0) { - Base::Console().Error("DPS::isOnEdge - simpleMinDist failed: %.3f\n",dist); + Base::Console().Error("DPS::isOnEdge - simpleMinDist failed: %.3f\n", dist); result = false; } else if (dist < Precision::Confusion()) { const gp_Pnt pt = BRep_Tool::Pnt(v); //have to duplicate method 3 to get param @@ -272,13 +272,13 @@ bool DrawProjectSplit::isOnEdge(TopoDS_Edge e, TopoDS_Vertex v, double& param, b const Handle(Geom_Curve) c = adapt.Curve().Curve(); double maxDist = 0.000001; //magic number. less than this gives false positives. //bool found = - (void) GeomLib_Tool::Parameter(c,pt,maxDist,param); //already know point it on curve + (void) GeomLib_Tool::Parameter(c, pt, maxDist, param); //already know point it on curve result = true; } if (result) { TopoDS_Vertex v1 = TopExp::FirstVertex(e); TopoDS_Vertex v2 = TopExp::LastVertex(e); - if (DrawUtil::isSamePoint(v,v1) || DrawUtil::isSamePoint(v,v2)) { + if (DrawUtil::isSamePoint(v, v1) || DrawUtil::isSamePoint(v, v2)) { if (!allowEnds) { result = false; } @@ -312,7 +312,7 @@ std::vector DrawProjectSplit::splitEdges(std::vector e iSplit++; } else if (ii > iEdge) { if (!edgeSplits.empty()) { //save *iedge's splits - newEdges = split1Edge(edges[iEdge],edgeSplits); + newEdges = split1Edge(edges[iEdge], edgeSplits); result.insert(result.end(), newEdges.begin(), newEdges.end()); edgeSplits.clear(); } else { @@ -325,7 +325,7 @@ std::vector DrawProjectSplit::splitEdges(std::vector e } if (!edgeSplits.empty()) { //handle last batch - newEdges = split1Edge(edges[iEdge],edgeSplits); + newEdges = split1Edge(edges[iEdge], edgeSplits); result.insert(result.end(), newEdges.begin(), newEdges.end()); edgeSplits.clear(); } @@ -361,7 +361,7 @@ std::vector DrawProjectSplit::split1Edge(TopoDS_Edge e, std::vector auto parms2 = parms.begin() + 1; std::vector::iterator psecond = parms2; std::vector::iterator pstop = parms.end(); - for (; psecond != pstop; ++pfirst,++psecond) { + for (; psecond != pstop; ++pfirst, ++psecond) { try { BRepBuilderAPI_MakeEdge mkEdge(c, *pfirst, *psecond); if (mkEdge.IsDone()) { @@ -381,7 +381,7 @@ std::vector DrawProjectSplit::sortSplits(std::vector& s, std::vector sorted = s; std::sort(sorted.begin(), sorted.end(), DrawProjectSplit::splitCompare); if (ascend) { - std::reverse(sorted.begin(),sorted.end()); + std::reverse(sorted.begin(), sorted.end()); } return sorted; } @@ -425,10 +425,10 @@ std::vector DrawProjectSplit::removeDuplicateEdges(std::vector DrawProjectSplit::removeDuplicateEdges(std::vector sorted = sortEdges(temp,true); + std::vector sorted = sortEdges(temp, true); auto last = std::unique(sorted.begin(), sorted.end(), edgeSortItem::edgeEqual); //duplicates to back sorted.erase(last, sorted.end()); //remove dupls @@ -450,7 +450,7 @@ std::vector DrawProjectSplit::removeDuplicateEdges(std::vector DrawProjectSplit::sortEdges(std::vector& std::vector sorted = e; std::sort(sorted.begin(), sorted.end(), edgeSortItem::edgeLess); if (ascend) { - std::reverse(sorted.begin(),sorted.end()); + std::reverse(sorted.begin(), sorted.end()); } return sorted; } @@ -496,7 +496,7 @@ std::string edgeSortItem::dump() } else if (!DrawUtil::fpCompare(e1.endAngle, e2.endAngle)) { if (e1.endAngle < e2.endAngle) { result = true; - } + } } else if (e1.idx < e2.idx) { result = true; } @@ -511,8 +511,8 @@ std::string edgeSortItem::dump() double endDif = (e1.end - e2.end).Length(); if ( (startDif < Precision::Confusion()) && (endDif < Precision::Confusion()) && - (DrawUtil::fpCompare(e1.startAngle,e2.startAngle)) && - (DrawUtil::fpCompare(e1.endAngle,e2.endAngle)) ) { + (DrawUtil::fpCompare(e1.startAngle, e2.startAngle)) && + (DrawUtil::fpCompare(e1.endAngle, e2.endAngle)) ) { result = true; } return result; diff --git a/src/Mod/TechDraw/App/DrawProjectSplit.h b/src/Mod/TechDraw/App/DrawProjectSplit.h index 58e0f12965..5320ca9b35 100644 --- a/src/Mod/TechDraw/App/DrawProjectSplit.h +++ b/src/Mod/TechDraw/App/DrawProjectSplit.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawProjectSplit_h_ -#define _DrawProjectSplit_h_ +#ifndef DrawProjectSplit_h_ +#define DrawProjectSplit_h_ #include @@ -57,7 +57,7 @@ public: startAngle = endAngle = 0.0; idx = 0; } - ~edgeSortItem() {} + ~edgeSortItem() = default; Base::Vector3d start; Base::Vector3d end; @@ -101,4 +101,4 @@ using DrawProjectSplitPython = App::FeaturePythonT; } //namespace TechDraw -#endif // #ifndef _DrawProjectSplit_h_ +#endif // #ifndef DrawProjectSplit_h_ diff --git a/src/Mod/TechDraw/App/DrawRichAnno.cpp b/src/Mod/TechDraw/App/DrawRichAnno.cpp index fb7aa68cdf..20a93bfc46 100644 --- a/src/Mod/TechDraw/App/DrawRichAnno.cpp +++ b/src/Mod/TechDraw/App/DrawRichAnno.cpp @@ -47,21 +47,17 @@ DrawRichAnno::DrawRichAnno() { static const char *group = "Text Block"; - ADD_PROPERTY_TYPE(AnnoParent,(nullptr),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(AnnoParent, (nullptr), group, (App::PropertyType)(App::Prop_None), "Object to which this annontation is attached"); ADD_PROPERTY_TYPE(AnnoText, (""), group, App::Prop_None, "Annotation text"); ADD_PROPERTY_TYPE(ShowFrame, (true), group, App::Prop_None, "Outline rectangle on/off"); ADD_PROPERTY_TYPE(MaxWidth, (-1.0), group, App::Prop_None, "Width limit before auto wrap"); - Caption.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Caption.setStatus(App::Property::Hidden, true); + Scale.setStatus(App::Property::Hidden, true); + ScaleType.setStatus(App::Property::Hidden, true); } -DrawRichAnno::~DrawRichAnno() -{ -} - void DrawRichAnno::onChanged(const App::Property* prop) { if (!isRestoring()) { @@ -71,7 +67,7 @@ void DrawRichAnno::onChanged(const App::Property* prop) requestPaint(); } } - + DrawView::onChanged(prop); } @@ -90,7 +86,7 @@ short DrawRichAnno::mustExecute() const } App::DocumentObjectExecReturn *DrawRichAnno::execute() -{ +{ // Base::Console().Message("DRA::execute() - @ (%.3f, %.3f)\n", X.getValue(), Y.getValue()); if (!keepUpdated()) { return App::DocumentObject::StdReturn; @@ -127,7 +123,7 @@ PyObject *DrawRichAnno::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawRichAnnoPy(this),true); + PythonObject = Py::Object(new DrawRichAnnoPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawRichAnno.h b/src/Mod/TechDraw/App/DrawRichAnno.h index aa92aac9a7..3a7ab19b0d 100644 --- a/src/Mod/TechDraw/App/DrawRichAnno.h +++ b/src/Mod/TechDraw/App/DrawRichAnno.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawRichAnno_h_ -#define _TechDraw_DrawRichAnno_h_ +#ifndef TechDraw_DrawRichAnno_h_ +#define TechDraw_DrawRichAnno_h_ #include @@ -39,7 +39,7 @@ class TechDrawExport DrawRichAnno : public TechDraw::DrawView public: DrawRichAnno(); - ~DrawRichAnno() override; + ~DrawRichAnno() = default; App::PropertyLink AnnoParent; App::PropertyString AnnoText; @@ -53,7 +53,7 @@ public: return "TechDrawGui::ViewProviderRichAnno"; } PyObject *getPyObject() override; - QRectF getRect() const override { return QRectF(0,0,1,1);} + QRectF getRect() const override { return { 0, 0, 1, 1}; } DrawView* getBaseView() const; DrawPage* findParentPage() const override; diff --git a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp index ab79410fce..5c32b0adbe 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplate.cpp @@ -73,9 +73,9 @@ DrawSVGTemplate::DrawSVGTemplate() ADD_PROPERTY_TYPE(Template, (""), group, App::Prop_Transient, "Template for the page"); //sb TemplateFileName??? // Width and Height properties shouldn't be set by the user - Height.setStatus(App::Property::ReadOnly,true); - Width.setStatus(App::Property::ReadOnly,true); - Orientation.setStatus(App::Property::ReadOnly,true); + Height.setStatus(App::Property::ReadOnly, true); + Width.setStatus(App::Property::ReadOnly, true); + Orientation.setStatus(App::Property::ReadOnly, true); std::string svgFilter("Svg files (*.svg *.SVG);;All files (*)"); Template.setFilter(svgFilter); @@ -89,7 +89,7 @@ PyObject *DrawSVGTemplate::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawSVGTemplatePy(this),true); + PythonObject = Py::Object(new DrawSVGTemplatePy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawSVGTemplate.h b/src/Mod/TechDraw/App/DrawSVGTemplate.h index 659e3098e5..ce1412276b 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplate.h +++ b/src/Mod/TechDraw/App/DrawSVGTemplate.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_DrawSVGTemplate_h_ -#define _TECHDRAW_DrawSVGTemplate_h_ +#ifndef TECHDRAW_DrawSVGTemplate_h_ +#define TECHDRAW_DrawSVGTemplate_h_ #include @@ -81,4 +81,4 @@ using DrawSVGTemplatePython = App::FeaturePythonT; } //namespace TechDraw -#endif //_TECHDRAW_DrawSVGTemplate_h_ +#endif //TECHDRAW_DrawSVGTemplate_h_ diff --git a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp index f7885a9ea0..589a665dcb 100644 --- a/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp +++ b/src/Mod/TechDraw/App/DrawSVGTemplatePyImp.cpp @@ -65,7 +65,7 @@ PyObject* DrawSVGTemplatePy::getEditFieldContent(PyObject* args) { PyObject* result = nullptr; char* fieldName; - if (!PyArg_ParseTuple(args, "s",&fieldName)) { + if (!PyArg_ParseTuple(args, "s", &fieldName)) { Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Arg\n"); return nullptr; } @@ -81,7 +81,7 @@ PyObject* DrawSVGTemplatePy::setEditFieldContent(PyObject* args) PyObject* result = Py_True; char* fieldName; char* newContent; - if (!PyArg_ParseTuple(args, "ss", &fieldName,&newContent)) { + if (!PyArg_ParseTuple(args, "ss", &fieldName, &newContent)) { Base::Console().Error("Error: DrawSVGTemplatePy::getEditFieldNames - Bad Args\n"); result = Py_False; } else { diff --git a/src/Mod/TechDraw/App/DrawTemplate.cpp b/src/Mod/TechDraw/App/DrawTemplate.cpp index 6e28a5bd3c..292d002084 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.cpp +++ b/src/Mod/TechDraw/App/DrawTemplate.cpp @@ -78,7 +78,7 @@ PyObject *DrawTemplate::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawTemplatePy(this),true); + PythonObject = Py::Object(new DrawTemplatePy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawTemplate.h b/src/Mod/TechDraw/App/DrawTemplate.h index d006d0e4d8..69149c5717 100644 --- a/src/Mod/TechDraw/App/DrawTemplate.h +++ b/src/Mod/TechDraw/App/DrawTemplate.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_DrawTemplate_h_ -#define _TECHDRAW_DrawTemplate_h_ +#ifndef TECHDRAW_DrawTemplate_h_ +#define TECHDRAW_DrawTemplate_h_ #include @@ -92,4 +92,4 @@ using DrawTemplatePython = App::FeaturePythonT; -#endif //_TECHDRAW_DrawTemplate_h_ +#endif //TECHDRAW_DrawTemplate_h_ diff --git a/src/Mod/TechDraw/App/DrawTile.cpp b/src/Mod/TechDraw/App/DrawTile.cpp index b93b663061..5b395ed0d9 100644 --- a/src/Mod/TechDraw/App/DrawTile.cpp +++ b/src/Mod/TechDraw/App/DrawTile.cpp @@ -47,7 +47,7 @@ DrawTile::DrawTile() { static const char *group = "Tile"; - ADD_PROPERTY_TYPE(TileParent,(nullptr),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(TileParent, (nullptr), group, (App::PropertyType)(App::Prop_None), "Object to which this tile is attached"); ADD_PROPERTY_TYPE(TileRow, (0), group, App::Prop_None, "Row in parent object\n 0 for arrow side, -1 for other side"); ADD_PROPERTY_TYPE(TileColumn, (0), group, App::Prop_None, "Column in parent object"); @@ -62,10 +62,6 @@ DrawTile::DrawTile() TileRow.setConstraints(&TileRowConstraints); } -DrawTile::~DrawTile() -{ -} - void DrawTile::onChanged(const App::Property* prop) { if (!isRestoring()) { @@ -108,7 +104,7 @@ PyObject *DrawTile::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawTilePy(this),true); + PythonObject = Py::Object(new DrawTilePy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawTile.h b/src/Mod/TechDraw/App/DrawTile.h index f604670f08..193d119734 100644 --- a/src/Mod/TechDraw/App/DrawTile.h +++ b/src/Mod/TechDraw/App/DrawTile.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawTile_h_ -#define _TechDraw_DrawTile_h_ +#ifndef TechDraw_DrawTile_h_ +#define TechDraw_DrawTile_h_ #include @@ -39,7 +39,7 @@ class TechDrawExport DrawTile : public App::DocumentObject public: DrawTile(); - ~DrawTile() override; + ~DrawTile() = default; App::PropertyLink TileParent; //eg DrawWeldSymbol App::PropertyIntegerConstraint TileRow; diff --git a/src/Mod/TechDraw/App/DrawTileWeld.cpp b/src/Mod/TechDraw/App/DrawTileWeld.cpp index 5badce1767..575bdfd239 100644 --- a/src/Mod/TechDraw/App/DrawTileWeld.cpp +++ b/src/Mod/TechDraw/App/DrawTileWeld.cpp @@ -52,7 +52,7 @@ DrawTileWeld::DrawTileWeld() { static const char *group = "TileWeld"; - ADD_PROPERTY_TYPE(LeftText,(""),group,(App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(LeftText, (""), group, (App::PropertyType)(App::Prop_None), "Text before symbol"); ADD_PROPERTY_TYPE(RightText, (nullptr), group, App::Prop_None, "Text after symbol"); ADD_PROPERTY_TYPE(CenterText, (nullptr), group, App::Prop_None, "Text above/below symbol"); @@ -60,7 +60,7 @@ DrawTileWeld::DrawTileWeld() ADD_PROPERTY_TYPE(SymbolIncluded, (""), group, App::Prop_None, "Embedded Symbol. System use only."); // n/a to end users -// SymbolFile.setStatus(App::Property::ReadOnly,true); +// SymbolFile.setStatus(App::Property::ReadOnly, true); std::string svgFilter("Symbol files (*.svg *.SVG);;All files (*)"); SymbolFile.setFilter(svgFilter); @@ -93,7 +93,7 @@ short DrawTileWeld::mustExecute() const } App::DocumentObjectExecReturn *DrawTileWeld::execute() -{ +{ // Base::Console().Message("DTW::execute()\n"); return DrawTile::execute(); } @@ -110,7 +110,7 @@ void DrawTileWeld::replaceSymbolIncluded(std::string newSymbolFile) } } -void DrawTileWeld::onDocumentRestored() +void DrawTileWeld::onDocumentRestored() { // Base::Console().Message("DTW::onDocumentRestored()\n"); if (SymbolIncluded.isEmpty()) { @@ -172,7 +172,7 @@ PyObject *DrawTileWeld::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawTileWeldPy(this),true); + PythonObject = Py::Object(new DrawTileWeldPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawTileWeld.h b/src/Mod/TechDraw/App/DrawTileWeld.h index afc37e1e30..9a8f6754a3 100644 --- a/src/Mod/TechDraw/App/DrawTileWeld.h +++ b/src/Mod/TechDraw/App/DrawTileWeld.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawTileWeld_h_ -#define _TechDraw_DrawTileWeld_h_ +#ifndef TechDraw_DrawTileWeld_h_ +#define TechDraw_DrawTileWeld_h_ #include @@ -59,7 +59,7 @@ public: return "TechDrawGui::ViewProviderTile"; } PyObject *getPyObject() override; - virtual QRectF getRect() const { return QRectF(0,0,1,1);} + virtual QRectF getRect() const { return { 0, 0, 1, 1}; } void replaceSymbolIncluded(std::string newSymbolFile); void setupSymbolIncluded(); diff --git a/src/Mod/TechDraw/App/DrawUtil.cpp b/src/Mod/TechDraw/App/DrawUtil.cpp index b5f8a825d9..30af767fbc 100644 --- a/src/Mod/TechDraw/App/DrawUtil.cpp +++ b/src/Mod/TechDraw/App/DrawUtil.cpp @@ -23,16 +23,16 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include -# include -# include +#include +#include +#include #include #include -# include -# include -# include -# include -# include +#include +#include +#include +#include +#include #include #include @@ -75,8 +75,6 @@ #include #include -#include "Preferences.h" -#include "GeometryObject.h" #include "DrawUtil.h" using namespace TechDraw; @@ -96,7 +94,7 @@ using namespace TechDraw; std::stringstream ErrorMsg; if (geomName.empty()) { - Base::Console().Log("DU::getIndexFromName(%s) - empty geometry name\n",geomName.c_str()); + Base::Console().Log("DU::getIndexFromName(%s) - empty geometry name\n", geomName.c_str()); throw Base::ValueError("getIndexFromName - empty geometry name"); } @@ -145,7 +143,7 @@ bool DrawUtil::isSamePoint(TopoDS_Vertex v1, TopoDS_Vertex v2, double tolerance) { gp_Pnt p1 = BRep_Tool::Pnt(v1); gp_Pnt p2 = BRep_Tool::Pnt(v2); - if (p1.IsEqual(p2,tolerance)) { + if (p1.IsEqual(p2, tolerance)) { return true; } return false; @@ -155,7 +153,7 @@ bool DrawUtil::isZeroEdge(TopoDS_Edge e, double tolerance) { TopoDS_Vertex vStart = TopExp::FirstVertex(e); TopoDS_Vertex vEnd = TopExp::LastVertex(e); - if (isSamePoint(vStart,vEnd, tolerance)) { + if (isSamePoint(vStart, vEnd, tolerance)) { //closed edge will have same V's but non-zero length GProp_GProps props; BRepGProp::LinearProperties(e, props); @@ -186,16 +184,16 @@ double DrawUtil::simpleMinDist(TopoDS_Shape s1, TopoDS_Shape s2) double DrawUtil::angleWithX(TopoDS_Edge e, bool reverse) { gp_Pnt gstart = BRep_Tool::Pnt(TopExp::FirstVertex(e)); - Base::Vector3d start(gstart.X(),gstart.Y(),gstart.Z()); + Base::Vector3d start(gstart.X(), gstart.Y(), gstart.Z()); gp_Pnt gend = BRep_Tool::Pnt(TopExp::LastVertex(e)); - Base::Vector3d end(gend.X(),gend.Y(),gend.Z()); + Base::Vector3d end(gend.X(), gend.Y(), gend.Z()); Base::Vector3d u; if (reverse) { u = start - end; } else { u = end - start; } - double result = atan2(u.y,u.x); + double result = atan2(u.y, u.x); if (result < 0) { result += 2.0 * M_PI; } @@ -211,9 +209,9 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) //find tangent @ v double adjust = 1.0; //occ tangent points in direction of curve. at lastVert we need to reverse it. BRepAdaptor_Curve adapt(e); - if (isFirstVert(e,v,tolerance)) { + if (isFirstVert(e, v,tolerance)) { param = adapt.FirstParameter(); - } else if (isLastVert(e,v,tolerance)) { + } else if (isLastVert(e, v,tolerance)) { param = adapt.LastParameter(); adjust = -1; } else { @@ -222,29 +220,29 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) //must be able to get non-terminal point parm from curve/ } - Base::Vector3d uVec(0.0,0.0,0.0); + Base::Vector3d uVec(0.0, 0.0, 0.0); gp_Dir uDir; - BRepLProp_CLProps prop(adapt,param,2,tolerance); + BRepLProp_CLProps prop(adapt, param, 2,tolerance); if (prop.IsTangentDefined()) { prop.Tangent(uDir); - uVec = Base::Vector3d(uDir.X(),uDir.Y(),uDir.Z()) * adjust; + uVec = Base::Vector3d(uDir.X(), uDir.Y(), uDir.Z()) * adjust; } else { //this bit is a little sketchy gp_Pnt gstart = BRep_Tool::Pnt(TopExp::FirstVertex(e)); - Base::Vector3d start(gstart.X(),gstart.Y(),gstart.Z()); + Base::Vector3d start(gstart.X(), gstart.Y(), gstart.Z()); gp_Pnt gend = BRep_Tool::Pnt(TopExp::LastVertex(e)); - Base::Vector3d end(gend.X(),gend.Y(),gend.Z()); - if (isFirstVert(e,v,tolerance)) { + Base::Vector3d end(gend.X(), gend.Y(), gend.Z()); + if (isFirstVert(e, v,tolerance)) { uVec = end - start; - } else if (isLastVert(e,v,tolerance)) { + } else if (isLastVert(e, v,tolerance)) { uVec = end - start; } else { gp_Pnt errPnt = BRep_Tool::Pnt(v); - Base::Console().Warning("angleWithX: Tangent not defined at (%.3f,%.3f,%.3f)\n",errPnt.X(),errPnt.Y(),errPnt.Z()); + Base::Console().Warning("angleWithX: Tangent not defined at (%.3f, %.3f, %.3f)\n", errPnt.X(), errPnt.Y(), errPnt.Z()); //throw ?????? } } - double result = atan2(uVec.y,uVec.x); + double result = atan2(uVec.y, uVec.x); if (result < 0) { //map from [-PI:PI] to [0:2PI] result += 2.0 * M_PI; } @@ -254,7 +252,7 @@ double DrawUtil::angleWithX(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) bool DrawUtil::isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) { TopoDS_Vertex first = TopExp::FirstVertex(e); - if (isSamePoint(first,v, tolerance)) { + if (isSamePoint(first, v, tolerance)) { return true; } return false; @@ -263,7 +261,7 @@ bool DrawUtil::isFirstVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) bool DrawUtil::isLastVert(TopoDS_Edge e, TopoDS_Vertex v, double tolerance) { TopoDS_Vertex last = TopExp::LastVertex(e); - if (isSamePoint(last,v, tolerance)) { + if (isSamePoint(last, v, tolerance)) { return true; } return false; @@ -281,7 +279,7 @@ bool DrawUtil::fpCompare(const double& d1, const double& d2, double tolerance) std::pair DrawUtil::boxIntersect2d(Base::Vector3d point, Base::Vector3d dirIn, double xRange, - double yRange) + double yRange) { std::pair result; Base::Vector3d p1, p2; @@ -341,15 +339,15 @@ std::pair DrawUtil::boxIntersect2d(Base::Vector3 Base::Vector3d DrawUtil::vertex2Vector(const TopoDS_Vertex& v) { gp_Pnt gp = BRep_Tool::Pnt(v); - return Base::Vector3d(gp.X(),gp.Y(),gp.Z()); + return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); } std::string DrawUtil::formatVector(const Base::Vector3d& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.x << "," << v.y << "," << v.z << ") "; -// builder << " (" << setw(6) << v.x << "," << setw(6) << v.y << "," << setw(6) << v.z << ") "; + builder << " (" << v.x << ", " << v.y << ", " << v.z << ") "; +// builder << " (" << setw(6) << v.x << ", " << setw(6) << v.y << ", " << setw(6) << v.z << ") "; return builder.str(); } @@ -357,7 +355,7 @@ std::string DrawUtil::formatVector(const gp_Dir& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") "; + builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") "; return builder.str(); } @@ -365,14 +363,14 @@ std::string DrawUtil::formatVector(const gp_Dir2d& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.X() << "," << v.Y() << ") "; + builder << " (" << v.X() << ", " << v.Y() << ") "; return builder.str(); } std::string DrawUtil::formatVector(const gp_Vec& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") "; + builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") "; return builder.str(); } @@ -380,7 +378,7 @@ std::string DrawUtil::formatVector(const gp_Pnt& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.X() << "," << v.Y() << "," << v.Z() << ") "; + builder << " (" << v.X() << ", " << v.Y() << ", " << v.Z() << ") "; return builder.str(); } @@ -388,7 +386,7 @@ std::string DrawUtil::formatVector(const gp_Pnt2d& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.X() << "," << v.Y() << ") "; + builder << " (" << v.X() << ", " << v.Y() << ") "; return builder.str(); } @@ -396,7 +394,7 @@ std::string DrawUtil::formatVector(const QPointF& v) { std::stringstream builder; builder << std::fixed << std::setprecision(3) ; - builder << " (" << v.x() << "," << v.y() << ") "; + builder << " (" << v.x() << ", " << v.y() << ") "; return builder.str(); } @@ -404,9 +402,9 @@ std::string DrawUtil::formatVector(const QPointF& v) bool DrawUtil::vectorLess(const Base::Vector3d& v1, const Base::Vector3d& v2) { if ((v1 - v2).Length() > Precision::Confusion()) { //ie v1 != v2 - if (!DrawUtil::fpCompare(v1.x,v2.x)) { + if (!DrawUtil::fpCompare(v1.x, v2.x)) { return v1.x < v2.x; - } else if (!DrawUtil::fpCompare(v1.y,v2.y)) { + } else if (!DrawUtil::fpCompare(v1.y, v2.y)) { return v1.y < v2.y; } else { return v1.z < v2.z; @@ -418,13 +416,13 @@ bool DrawUtil::vectorLess(const Base::Vector3d& v1, const Base::Vector3d& v2) //!convert fromPoint in coordinate system fromSystem to reference coordinate system Base::Vector3d DrawUtil::toR3(const gp_Ax2& fromSystem, const Base::Vector3d& fromPoint) { - gp_Pnt gFromPoint(fromPoint.x,fromPoint.y,fromPoint.z); + gp_Pnt gFromPoint(fromPoint.x, fromPoint.y, fromPoint.z); gp_Trsf T; gp_Ax3 gRef; gp_Ax3 gFrom(fromSystem); T.SetTransformation (gFrom, gRef); gp_Pnt gToPoint = gFromPoint.Transformed(T); - Base::Vector3d toPoint(gToPoint.X(),gToPoint.Y(),gToPoint.Z()); + Base::Vector3d toPoint(gToPoint.X(), gToPoint.Y(), gToPoint.Z()); return toPoint; } @@ -433,7 +431,7 @@ bool DrawUtil::checkParallel(const Base::Vector3d v1, Base::Vector3d v2, double { double dot = fabs(v1.Dot(v2)); double mag = v1.Length() * v2.Length(); - if (DrawUtil::fpCompare(dot,mag,tolerance)) { + if (DrawUtil::fpCompare(dot, mag, tolerance)) { return true; } return false; @@ -446,29 +444,29 @@ Base::Vector3d DrawUtil::vecRotate(Base::Vector3d vec, Base::Vector3d org) { Base::Matrix4D xForm; - xForm.rotLine(org,axis,angle); + xForm.rotLine(org, axis, angle); return Base::Vector3d(xForm * (vec)); } Base::Vector3d DrawUtil::closestBasis(Base::Vector3d v) { - Base::Vector3d result(0.0,-1,0); - Base::Vector3d stdX(1.0,0.0,0.0); - Base::Vector3d stdY(0.0,1.0,0.0); - Base::Vector3d stdZ(0.0,0.0,1.0); - Base::Vector3d stdXr(-1.0,0.0,0.0); - Base::Vector3d stdYr(0.0,-1.0,0.0); - Base::Vector3d stdZr(0.0,0.0,-1.0); + Base::Vector3d result(0.0, -1, 0); + Base::Vector3d stdX(1.0, 0.0, 0.0); + Base::Vector3d stdY(0.0, 1.0, 0.0); + Base::Vector3d stdZ(0.0, 0.0, 1.0); + Base::Vector3d stdXr(-1.0, 0.0, 0.0); + Base::Vector3d stdYr(0.0, -1.0, 0.0); + Base::Vector3d stdZr(0.0, 0.0, -1.0); //first check if already a basis - if (checkParallel(v,stdZ) || - checkParallel(v,stdY) || - checkParallel(v,stdX)) { + if (checkParallel(v, stdZ) || + checkParallel(v, stdY) || + checkParallel(v, stdX)) { return v; } //not a basis. find smallest angle with a basis. - double angleX,angleY,angleZ,angleXr,angleYr,angleZr, angleMin; + double angleX, angleY, angleZ, angleXr, angleYr, angleZr, angleMin; angleX = stdX.GetAngle(v); angleY = stdY.GetAngle(v); angleZ = stdZ.GetAngle(v); @@ -532,7 +530,7 @@ bool DrawUtil::isBetween(const Base::Vector3d pt, const Base::Vector3d end1, con double segLength = (end2 - end1).Length(); double l1 = (pt - end1).Length(); double l2 = (pt - end2).Length(); - if (fpCompare(segLength,l1 + l2)) { + if (fpCompare(segLength, l1 + l2)) { return true; } return false; @@ -617,12 +615,12 @@ QPointF DrawUtil::invertY(QPointF v) //obs? was used in CSV prototype of Cosmetics std::vector DrawUtil::split(std::string csvLine) { -// Base::Console().Message("DU::split - csvLine: %s\n",csvLine.c_str()); +// Base::Console().Message("DU::split - csvLine: %s\n", csvLine.c_str()); std::vector result; std::stringstream lineStream(csvLine); std::string cell; - while(std::getline(lineStream,cell, ',')) + while(std::getline(lineStream, cell, ',')) { result.push_back(cell); } @@ -632,7 +630,7 @@ std::vector DrawUtil::split(std::string csvLine) //obs? was used in CSV prototype of Cosmetics std::vector DrawUtil::tokenize(std::string csvLine, std::string delimiter) { -// Base::Console().Message("DU::tokenize - csvLine: %s delimit: %s\n",csvLine.c_str(), delimiter.c_str()); +// Base::Console().Message("DU::tokenize - csvLine: %s delimit: %s\n", csvLine.c_str(), delimiter.c_str()); std::string s(csvLine); size_t pos = 0; std::vector tokens; @@ -656,15 +654,15 @@ App::Color DrawUtil::pyTupleToColor(PyObject* pColor) int tSize = (int) PyTuple_Size(pColor); if (tSize > 2) { - PyObject* pRed = PyTuple_GetItem(pColor,0); + PyObject* pRed = PyTuple_GetItem(pColor, 0); red = PyFloat_AsDouble(pRed); - PyObject* pGreen = PyTuple_GetItem(pColor,1); + PyObject* pGreen = PyTuple_GetItem(pColor, 1); green = PyFloat_AsDouble(pGreen); - PyObject* pBlue = PyTuple_GetItem(pColor,2); + PyObject* pBlue = PyTuple_GetItem(pColor, 2); blue = PyFloat_AsDouble(pBlue); } if (tSize > 3) { - PyObject* pAlpha = PyTuple_GetItem(pColor,3); + PyObject* pAlpha = PyTuple_GetItem(pColor, 3); alpha = PyFloat_AsDouble(pAlpha); } return App::Color(red, green, blue, alpha); @@ -679,10 +677,10 @@ PyObject* DrawUtil::colorToPyTuple(App::Color color) PyObject* pBlue = PyFloat_FromDouble(color.b); PyObject* pAlpha = PyFloat_FromDouble(color.a); - PyTuple_SET_ITEM(pTuple, 0,pRed); - PyTuple_SET_ITEM(pTuple, 1,pGreen); - PyTuple_SET_ITEM(pTuple, 2,pBlue); - PyTuple_SET_ITEM(pTuple, 3,pAlpha); + PyTuple_SET_ITEM(pTuple, 0, pRed); + PyTuple_SET_ITEM(pTuple, 1, pGreen); + PyTuple_SET_ITEM(pTuple, 2, pBlue); + PyTuple_SET_ITEM(pTuple, 3, pAlpha); return pTuple; } @@ -709,24 +707,24 @@ bool DrawUtil::isCrazy(TopoDS_Edge e) Base::Console().Log("DU::isCrazy - edge crazy short: %.7f\n", edgeLength); return true; } - if (edgeLength > 9999.9) { //edge is scaled. this is 10 m on paper. can't be right? + if (edgeLength > 9999.9) { //edge is scaled. this is 10 m on paper. can't be right? Base::Console().Log("DU::isCrazy - edge crazy long: %.3f\n", edgeLength); return true; } double start = BRepLProp_CurveTool::FirstParameter(adapt); double end = BRepLProp_CurveTool::LastParameter(adapt); - BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion()); + BRepLProp_CLProps propStart(adapt, start, 0,Precision::Confusion()); const gp_Pnt& vStart = propStart.Value(); - BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion()); + BRepLProp_CLProps propEnd(adapt, end, 0,Precision::Confusion()); const gp_Pnt& vEnd = propEnd.Value(); double distance = vStart.Distance(vEnd); double ratio = edgeLength / distance; if (adapt.GetType() == GeomAbs_BSplineCurve && distance > 0.001 && // not a closed loop - ratio > 9999.9) { // 10,000x + ratio > 9999.9) { // 10, 000x return true; //this is crazy edge - } + } else if (adapt.GetType() == GeomAbs_Ellipse) { gp_Elips ellp = adapt.Ellipse(); double major = ellp.MajorRadius(); @@ -742,7 +740,7 @@ bool DrawUtil::isCrazy(TopoDS_Edge e) // Base::Console().Message("DU::isCrazy - returns: %d ratio: %.3f\n", false, ratio); return false; -} +} //construct a compound shape from a list of edges TopoDS_Shape DrawUtil::vectorToCompound(std::vector vecIn) @@ -765,13 +763,13 @@ Base::Vector3d DrawUtil::getFaceCenter(TopoDS_Face f) double v1 = adapt.FirstVParameter(); double v2 = adapt.LastVParameter(); double mv = (v1 + v2) / 2.0; - BRepLProp_SLProps prop(adapt,mu,mv,0,Precision::Confusion()); + BRepLProp_SLProps prop(adapt, mu, mv, 0,Precision::Confusion()); const gp_Pnt gv = prop.Value(); return Base::Vector3d(gv.X(), gv.Y(), gv.Z()); } // test the circulation of the triangle A-B-C -bool DrawUtil::circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C) +bool DrawUtil::circulation(Base::Vector3d A, Base::Vector3d B, Base::Vector3d C) { if (A.x * B.y + A.y * C.x + B.x * C.y - C.x * B.y - C.y * A.x - B.x * A.y > 0.0) return true; @@ -1176,12 +1174,12 @@ void DrawUtil::copyFile(std::string inSpec, std::string outSpec) // various debugging routines. void DrawUtil::dumpVertexes(const char* text, const TopoDS_Shape& s) { - Base::Console().Message("DUMP - %s\n",text); + Base::Console().Message("DUMP - %s\n", text); TopExp_Explorer expl(s, TopAbs_VERTEX); - for (int i = 1 ; expl.More(); expl.Next(),i++) { + for (int i = 1 ; expl.More(); expl.Next(), i++) { const TopoDS_Vertex& v = TopoDS::Vertex(expl.Current()); gp_Pnt pnt = BRep_Tool::Pnt(v); - Base::Console().Message("v%d: (%.3f,%.3f,%.3f)\n",i,pnt.X(),pnt.Y(),pnt.Z()); + Base::Console().Message("v%d: (%.3f, %.3f, %.3f)\n", i,pnt.X(), pnt.Y(), pnt.Z()); } } @@ -1190,7 +1188,7 @@ void DrawUtil::countFaces(const char* text, const TopoDS_Shape& s) TopTools_IndexedMapOfShape mapOfFaces; TopExp::MapShapes(s, TopAbs_FACE, mapOfFaces); int num = mapOfFaces.Extent(); - Base::Console().Message("COUNT - %s has %d Faces\n",text,num); + Base::Console().Message("COUNT - %s has %d Faces\n", text, num); } //count # of unique Wires in shape. @@ -1199,7 +1197,7 @@ void DrawUtil::countWires(const char* text, const TopoDS_Shape& s) TopTools_IndexedMapOfShape mapOfWires; TopExp::MapShapes(s, TopAbs_WIRE, mapOfWires); int num = mapOfWires.Extent(); - Base::Console().Message("COUNT - %s has %d wires\n",text,num); + Base::Console().Message("COUNT - %s has %d wires\n", text, num); } void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s) @@ -1207,14 +1205,14 @@ void DrawUtil::countEdges(const char* text, const TopoDS_Shape& s) TopTools_IndexedMapOfShape mapOfEdges; TopExp::MapShapes(s, TopAbs_EDGE, mapOfEdges); int num = mapOfEdges.Extent(); - Base::Console().Message("COUNT - %s has %d edges\n",text,num); + Base::Console().Message("COUNT - %s has %d edges\n", text, num); } void DrawUtil::dumpEdges(const char* text, const TopoDS_Shape& s) { - Base::Console().Message("DUMP - %s\n",text); + Base::Console().Message("DUMP - %s\n", text); TopExp_Explorer expl(s, TopAbs_EDGE); - for (int i = 1 ; expl.More(); expl.Next(),i++) { + for (int i = 1 ; expl.More(); expl.Next(), i++) { const TopoDS_Edge& e = TopoDS::Edge(expl.Current()); dumpEdge("dumpEdges", i, e); } @@ -1222,9 +1220,9 @@ void DrawUtil::dumpEdges(const char* text, const TopoDS_Shape& s) void DrawUtil::dump1Vertex(const char* text, const TopoDS_Vertex& v) { - Base::Console().Message("DUMP - dump1Vertex - %s\n",text); + Base::Console().Message("DUMP - dump1Vertex - %s\n", text); gp_Pnt pnt = BRep_Tool::Pnt(v); - Base::Console().Message("%s: (%.3f,%.3f,%.3f)\n",text,pnt.X(),pnt.Y(),pnt.Z()); + Base::Console().Message("%s: (%.3f, %.3f, %.3f)\n", text, pnt.X(), pnt.Y(), pnt.Z()); } void DrawUtil::dumpEdge(const char* label, int i, TopoDS_Edge e) @@ -1232,14 +1230,14 @@ void DrawUtil::dumpEdge(const char* label, int i, TopoDS_Edge e) BRepAdaptor_Curve adapt(e); double start = BRepLProp_CurveTool::FirstParameter(adapt); double end = BRepLProp_CurveTool::LastParameter(adapt); - BRepLProp_CLProps propStart(adapt,start,0,Precision::Confusion()); + BRepLProp_CLProps propStart(adapt, start, 0,Precision::Confusion()); const gp_Pnt& vStart = propStart.Value(); - BRepLProp_CLProps propEnd(adapt,end,0,Precision::Confusion()); + BRepLProp_CLProps propEnd(adapt, end, 0,Precision::Confusion()); const gp_Pnt& vEnd = propEnd.Value(); - //Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f)/%0.3f end:(%.2f,%.3f,%.3f)/%.3f\n",label,i, - // vStart.X(),vStart.Y(),vStart.Z(),start,vEnd.X(),vEnd.Y(),vEnd.Z(),end); - Base::Console().Message("%s edge:%d start:(%.3f,%.3f,%.3f) end:(%.2f,%.3f,%.3f) Orient: %d\n",label,i, - vStart.X(),vStart.Y(),vStart.Z(),vEnd.X(),vEnd.Y(),vEnd.Z(), e.Orientation()); + //Base::Console().Message("%s edge:%d start:(%.3f, %.3f, %.3f)/%0.3f end:(%.2f, %.3f, %.3f)/%.3f\n", label, i, + // vStart.X(), vStart.Y(), vStart.Z(), start, vEnd.X(), vEnd.Y(), vEnd.Z(), end); + Base::Console().Message("%s edge:%d start:(%.3f, %.3f, %.3f) end:(%.2f, %.3f, %.3f) Orient: %d\n", label, i, + vStart.X(), vStart.Y(), vStart.Z(), vEnd.X(), vEnd.Y(), vEnd.Z(), e.Orientation()); double edgeLength = GCPnts_AbscissaPoint::Length(adapt, Precision::Confusion()); Base::Console().Message(">>>>>>> length: %.3f distance: %.3f ration: %.3f type: %d\n", edgeLength, vStart.Distance(vEnd), edgeLength / vStart.Distance(vEnd), adapt.GetType()); diff --git a/src/Mod/TechDraw/App/DrawUtil.h b/src/Mod/TechDraw/App/DrawUtil.h index 9c7b208712..cf2a4fd7e2 100644 --- a/src/Mod/TechDraw/App/DrawUtil.h +++ b/src/Mod/TechDraw/App/DrawUtil.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawUtil_h_ -#define _DrawUtil_h_ +#ifndef DrawUtil_h_ +#define DrawUtil_h_ #include @@ -99,11 +99,11 @@ class TechDrawExport DrawUtil { static Base::Vector3d vecRotate(Base::Vector3d vec, double angle, Base::Vector3d axis, - Base::Vector3d org = Base::Vector3d(0.0,0.0,0.0)); + Base::Vector3d org = Base::Vector3d(0.0, 0.0, 0.0)); static Base::Vector3d closestBasis(Base::Vector3d v); static double getDefaultLineWeight(std::string s); -/* static Base::Vector3d vector23(const Base::Vector3d& v2) { return Base::Vector3d(v2.x,v2.y,0.0); }*/ -/* static Base::Vector3d vector32(const Base::Vector3d& v3) { return Base::Vector3d(v3.x,v3.y); }*/ +/* static Base::Vector3d vector23(const Base::Vector3d& v2) { return Base::Vector3d(v2.x, v2.y, 0.0); }*/ +/* static Base::Vector3d vector32(const Base::Vector3d& v3) { return Base::Vector3d(v3.x, v3.y); }*/ //! is pt between end1 and end2? static bool isBetween(const Base::Vector3d pt, const Base::Vector3d end1, const Base::Vector3d end2); //! find intersection in 2d for 2 lines in point+direction form @@ -111,14 +111,14 @@ class TechDrawExport DrawUtil { Base::Vector3d p2, Base::Vector3d d2); static Base::Vector2d Intersect2d(Base::Vector2d p1, Base::Vector2d d1, Base::Vector2d p2, Base::Vector2d d2); - static Base::Vector3d gpPnt2V3(const gp_Pnt gp) { return Base::Vector3d(gp.X(),gp.Y(),gp.Z()); } - static gp_Pnt V32gpPnt(const Base::Vector3d v) { return gp_Pnt(v.x,v.y,v.z); } + static Base::Vector3d gpPnt2V3(const gp_Pnt gp) { return Base::Vector3d(gp.X(), gp.Y(), gp.Z()); } + static gp_Pnt V32gpPnt(const Base::Vector3d v) { return gp_Pnt(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); static QPointF invertY(QPointF p); static std::vector split(std::string csvLine); - static std::vector tokenize(std::string csvLine, std::string delimiter = ",$$$,"); + static std::vector tokenize(std::string csvLine, std::string delimiter = ", $$$, "); static App::Color pyTupleToColor(PyObject* pColor); static PyObject* colorToPyTuple(App::Color color); static bool isCrazy(TopoDS_Edge e); diff --git a/src/Mod/TechDraw/App/DrawView.cpp b/src/Mod/TechDraw/App/DrawView.cpp index 390a8e4125..058c93a430 100644 --- a/src/Mod/TechDraw/App/DrawView.cpp +++ b/src/Mod/TechDraw/App/DrawView.cpp @@ -43,13 +43,9 @@ #include "DrawPage.h" #include "DrawViewCollection.h" #include "DrawViewClip.h" -#include "DrawProjGroup.h" -#include "DrawProjGroupItem.h" #include "DrawLeaderLine.h" #include "Preferences.h" #include "DrawUtil.h" -#include "Geometry.h" -#include "Cosmetic.h" #include // generated from DrawViewPy.xml @@ -65,9 +61,10 @@ const char* DrawView::ScaleTypeEnums[]= {"Page", "Automatic", "Custom", nullptr}; +const double SCALEINCREMENT(0.1); App::PropertyFloatConstraint::Constraints DrawView::scaleRange = {Precision::Confusion(), std::numeric_limits::max(), - (0.1)}; // increment by 0.1 + (SCALEINCREMENT)}; // increment by 0.1 PROPERTY_SOURCE(TechDraw::DrawView, App::DocumentObject) @@ -128,40 +125,46 @@ void DrawView::onChanged(const App::Property* prop) //Coding note: calling execute, recompute or recomputeFeature inside an onChanged //method can create infinite loops if the called method changes a property. In general //don't do this! There are situations where it is OK, but careful analysis is a must. - if (!isRestoring()) { - if (prop == &ScaleType) { - auto page = findParentPage(); - if (ScaleType.isValue("Page")) { - Scale.setStatus(App::Property::ReadOnly, true); - if (page) { - if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) { - Scale.setValue(page->Scale.getValue()); - } - } - } else if ( ScaleType.isValue("Custom") ) { - //don't change Scale - Scale.setStatus(App::Property::ReadOnly, false); - } else if ( ScaleType.isValue("Automatic") ) { - Scale.setStatus(App::Property::ReadOnly, true); - if (!checkFit(page)) { - double newScale = autoScale(page->getPageWidth(), page->getPageHeight()); - if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop - Scale.setValue(newScale); - } + if (isRestoring()) { + App::DocumentObject::onChanged(prop); + return; + } + + if (prop == &ScaleType) { + auto page = findParentPage(); + if (!page) { + //we don't belong to a page yet, so don't bother + return; + } + if (ScaleType.isValue("Page")) { + Scale.setStatus(App::Property::ReadOnly, true); + if(std::abs(page->Scale.getValue() - getScale()) > FLT_EPSILON) { + Scale.setValue(page->Scale.getValue()); + } + } else if ( ScaleType.isValue("Custom") ) { + //don't change Scale + Scale.setStatus(App::Property::ReadOnly, false); + } else if ( ScaleType.isValue("Automatic") ) { + Scale.setStatus(App::Property::ReadOnly, true); + if (!checkFit(page)) { + double newScale = autoScale(page->getPageWidth(), page->getPageHeight()); + if(std::abs(newScale - getScale()) > FLT_EPSILON) { //stops onChanged/execute loop + Scale.setValue(newScale); } } - } else if (prop == &LockPosition) { - handleXYLock(); - requestPaint(); //change lock icon - LockPosition.purgeTouched(); - } else if ((prop == &Caption) || - (prop == &Label)) { - requestPaint(); - } else if ((prop == &X) || - (prop == &Y)) { - //X,Y changes are only interesting to DPGI and Gui side } + } else if (prop == &LockPosition) { + handleXYLock(); + requestPaint(); //change lock icon + LockPosition.purgeTouched(); + } else if ((prop == &Caption) || + (prop == &Label)) { + requestPaint(); + } else if ( prop == &X || + prop == &Y ) { + //X,Y changes are only interesting to DPGI and Gui side } + App::DocumentObject::onChanged(prop); } @@ -215,7 +218,7 @@ short DrawView::mustExecute() const ////you must override this in derived class QRectF DrawView::getRect() const { - QRectF result(0,0,1,1); + QRectF result(0, 0,1, 1); return result; } @@ -224,7 +227,6 @@ void DrawView::onDocumentRestored() handleXYLock(); setScaleAttribute(); validateScale(); - DrawView::execute(); } //in versions before 0.20 Scale and ScaleType were mishandled. @@ -244,7 +246,6 @@ void DrawView::validateScale() double myScale = Scale.getValue(); if (!DrawUtil::fpCompare(pageScale, myScale)) { ScaleType.setValue("Custom"); - ScaleType.purgeTouched(); } } } @@ -357,10 +358,10 @@ double DrawView::autoScale() const auto page = findParentPage(); double w = page->getPageWidth(); double h = page->getPageHeight(); - return autoScale(w,h); + return autoScale(w, h); } -//compare 1:1 rect of view to pagesize(pw,h) +//compare 1:1 rect of view to pagesize(pw, h) double DrawView::autoScale(double pw, double ph) const { // Base::Console().Message("DV::autoScale(Page: %.3f, %.3f) - %s\n", pw, ph, getNameInDocument()); @@ -374,7 +375,7 @@ double DrawView::autoScale(double pw, double ph) const double vbh = viewBox.height()/getScale(); double xScale = pw/vbw; // > 1 page bigger than figure double yScale = ph/vbh; // < 1 page is smaller than figure - double newScale = std::min(xScale,yScale) * fudgeFactor; + double newScale = std::min(xScale, yScale) * fudgeFactor; double sensibleScale = DrawUtil::sensibleScale(newScale); return sensibleScale; } @@ -413,7 +414,7 @@ bool DrawView::checkFit(TechDraw::DrawPage* p) const void DrawView::setPosition(double x, double y, bool force) { -// Base::Console().Message("DV::setPosition(%.3f,%.3f) - \n",x,y,getNameInDocument()); +// Base::Console().Message("DV::setPosition(%.3f, %.3f) - \n", x,y, getNameInDocument()); if ( (!isLocked()) || (force) ) { double currX = X.getValue(); @@ -438,7 +439,7 @@ double DrawView::getScale() const } if (!(result > 0.0)) { result = 1.0; - Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n",getNameInDocument(),Scale.getValue()); + Base::Console().Log("DrawView - %s - bad scale found (%.3f) using 1.0\n", getNameInDocument(), Scale.getValue()); } return result; } @@ -461,7 +462,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T { if (prop == &Scale) { App::PropertyFloat tmp; - if (strcmp(tmp.getTypeId().getName(),TypeName)==0) { //property in file is Float + if (strcmp(tmp.getTypeId().getName(), TypeName)==0) { //property in file is Float tmp.setContainer(this); tmp.Restore(reader); double tmpValue = tmp.getValue(); @@ -499,7 +500,7 @@ void DrawView::handleChangedPropertyType(Base::XMLReader &reader, const char * T } // property X had App::PropertyFloat and was changed to App::PropertyLength - // and later to PropertyDistance because some X,Y are relative to existing points on page + // and later to PropertyDistance because some X, Y are relative to existing points on page else if (prop == &X && strcmp(TypeName, "App::PropertyFloat") == 0) { App::PropertyFloat XProperty; XProperty.setContainer(this); @@ -550,7 +551,7 @@ void DrawView::setScaleAttribute() { if (ScaleType.isValue("Page") || ScaleType.isValue("Automatic")) { - Scale.setStatus(App::Property::ReadOnly,true); + Scale.setStatus(App::Property::ReadOnly, true); } else { Scale.setStatus(App::Property::ReadOnly, false); } @@ -568,7 +569,7 @@ double DrawView::prefScale() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - double result = hGrp->GetFloat("DefaultViewScale", 1.0); + double result = hGrp->GetFloat("DefaultViewScale", 1.0); if (ScaleType.isValue("Page")) { auto page = findParentPage(); if (page) { @@ -595,7 +596,7 @@ PyObject *DrawView::getPyObject(void) { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewPy(this),true); + PythonObject = Py::Object(new DrawViewPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawView.h b/src/Mod/TechDraw/App/DrawView.h index 24976d9b59..3d24d03548 100644 --- a/src/Mod/TechDraw/App/DrawView.h +++ b/src/Mod/TechDraw/App/DrawView.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawView_h_ -#define _DrawView_h_ +#ifndef DrawView_h_ +#define DrawView_h_ #include diff --git a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp index 8a4de555e0..c560088f21 100644 --- a/src/Mod/TechDraw/App/DrawViewAnnotation.cpp +++ b/src/Mod/TechDraw/App/DrawViewAnnotation.cpp @@ -59,20 +59,20 @@ DrawViewAnnotation::DrawViewAnnotation() { static const char *vgroup = "Annotation"; - ADD_PROPERTY_TYPE(Text ,("Default Text"),vgroup,App::Prop_None,"Annotation text"); + ADD_PROPERTY_TYPE(Text ,("Default Text"), vgroup, App::Prop_None, "Annotation text"); ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()), - vgroup,App::Prop_None, "Font name"); - ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"Text color"); + vgroup, App::Prop_None, "Font name"); + ADD_PROPERTY_TYPE(TextColor, (0.0f, 0.0f, 0.0f), vgroup, App::Prop_None, "Text color"); ADD_PROPERTY_TYPE(TextSize, (Preferences::labelFontSizeMM()), - vgroup,App::Prop_None,"Text size"); - ADD_PROPERTY_TYPE(MaxWidth,(-1.0),vgroup,App::Prop_None,"Maximum width of the annotation block.\n -1 means no maximum width."); - ADD_PROPERTY_TYPE(LineSpace,(80),vgroup,App::Prop_None,"Line spacing in %. 100 means the height of a line."); + vgroup, App::Prop_None, "Text size"); + ADD_PROPERTY_TYPE(MaxWidth, (-1.0), vgroup, App::Prop_None, "Maximum width of the annotation block.\n -1 means no maximum width."); + ADD_PROPERTY_TYPE(LineSpace, (80), vgroup, App::Prop_None, "Line spacing in %. 100 means the height of a line."); TextStyle.setEnums(TextStyleEnums); - ADD_PROPERTY_TYPE(TextStyle,((long)0),vgroup,App::Prop_None,"Text style"); + ADD_PROPERTY_TYPE(TextStyle, ((long)0), vgroup, App::Prop_None, "Text style"); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Scale.setStatus(App::Property::Hidden, true); + ScaleType.setStatus(App::Property::Hidden, true); } DrawViewAnnotation::~DrawViewAnnotation() @@ -100,7 +100,7 @@ void DrawViewAnnotation::handleChangedPropertyType(Base::XMLReader &reader, cons { // also check for changed properties of the base class DrawView::handleChangedPropertyType(reader, TypeName, prop); - + // property LineSpace had the App::PropertyInteger and was changed to App::PropertyPercent if (prop == &LineSpace && strcmp(TypeName, "App::PropertyInteger") == 0) { App::PropertyInteger LineSpaceProperty; @@ -126,9 +126,9 @@ QRectF DrawViewAnnotation::getRect() const chars = (int)l.size(); } } - int w = chars * std::max(1,(int)tSize); - int h = lines * std::max(1,(int)tSize); - return QRectF(0,0,getScale() * w,getScale() * h); + int w = chars * std::max(1, (int)tSize); + int h = lines * std::max(1, (int)tSize); + return { 0, 0, getScale() * w, getScale() * h}; } App::DocumentObjectExecReturn *DrawViewAnnotation::execute() diff --git a/src/Mod/TechDraw/App/DrawViewAnnotation.h b/src/Mod/TechDraw/App/DrawViewAnnotation.h index 488023b13b..6d55799ba0 100644 --- a/src/Mod/TechDraw/App/DrawViewAnnotation.h +++ b/src/Mod/TechDraw/App/DrawViewAnnotation.h @@ -21,8 +21,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewAnnotation_h_ -#define _DrawViewAnnotation_h_ +#ifndef DrawViewAnnotation_h_ +#define DrawViewAnnotation_h_ #include @@ -51,7 +51,7 @@ public: App::PropertyColor TextColor; App::PropertyLength TextSize; App::PropertyPercent LineSpace; - App::PropertyEnumeration TextStyle; // Plain,Bold,Italic,Bold-Italic + App::PropertyEnumeration TextStyle; // Plain, Bold, Italic, Bold-Italic App::PropertyLength MaxWidth; QRectF getRect() const override; diff --git a/src/Mod/TechDraw/App/DrawViewArch.cpp b/src/Mod/TechDraw/App/DrawViewArch.cpp index ac7347ee5f..11d018ac7d 100644 --- a/src/Mod/TechDraw/App/DrawViewArch.cpp +++ b/src/Mod/TechDraw/App/DrawViewArch.cpp @@ -56,25 +56,21 @@ DrawViewArch::DrawViewArch() { static const char *group = "Arch view"; - ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"SectionPlane or BuildingPart object for this view"); + ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "SectionPlane or BuildingPart object for this view"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(AllOn ,(false),group,App::Prop_None,"If hidden objects must be shown or not"); + ADD_PROPERTY_TYPE(AllOn ,(false), group, App::Prop_None, "If hidden objects must be shown or not"); RenderMode.setEnums(RenderModeEnums); - ADD_PROPERTY_TYPE(RenderMode, ((long)0),group,App::Prop_None,"The render mode to use"); - ADD_PROPERTY_TYPE(FillSpaces ,(false),group,App::Prop_None,"If True, Arch Spaces are shown as a colored area"); - ADD_PROPERTY_TYPE(ShowHidden ,(false),group,App::Prop_None,"If the hidden geometry behind the section plane is shown or not"); - ADD_PROPERTY_TYPE(ShowFill ,(false),group,App::Prop_None,"If cut areas must be filled with a hatch pattern or not"); - ADD_PROPERTY_TYPE(LineWidth,(0.25),group,App::Prop_None,"Line width of this view"); - ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view"); - ADD_PROPERTY_TYPE(CutLineWidth,(0.50),group,App::Prop_None,"Width of cut lines of this view"); - ADD_PROPERTY_TYPE(JoinArch ,(false),group,App::Prop_None,"If True, walls and structure will be fused by material"); + ADD_PROPERTY_TYPE(RenderMode, ((long)0), group, App::Prop_None, "The render mode to use"); + ADD_PROPERTY_TYPE(FillSpaces ,(false), group, App::Prop_None, "If True, Arch Spaces are shown as a colored area"); + ADD_PROPERTY_TYPE(ShowHidden ,(false), group, App::Prop_None, "If the hidden geometry behind the section plane is shown or not"); + ADD_PROPERTY_TYPE(ShowFill ,(false), group, App::Prop_None, "If cut areas must be filled with a hatch pattern or not"); + ADD_PROPERTY_TYPE(LineWidth, (0.25), group, App::Prop_None, "Line width of this view"); + ADD_PROPERTY_TYPE(FontSize, (12.0), group, App::Prop_None, "Text size for this view"); + ADD_PROPERTY_TYPE(CutLineWidth, (0.50), group, App::Prop_None, "Width of cut lines of this view"); + ADD_PROPERTY_TYPE(JoinArch ,(false), group, App::Prop_None, "If True, walls and structure will be fused by material"); ScaleType.setValue("Custom"); } -DrawViewArch::~DrawViewArch() -{ -} - //NOTE: DocumentObject::mustExecute returns 1/0 and not true/false short DrawViewArch::mustExecute() const { @@ -118,27 +114,27 @@ App::DocumentObjectExecReturn *DrawViewArch::execute() std::string svgTail = getSVGTail(); std::string FeatName = getNameInDocument(); std::string SourceName = sourceObj->getNameInDocument(); - // ArchSectionPlane.getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1): + // ArchSectionPlane.getSVG(section, allOn=False, renderMode="Wireframe", showHidden=False, showFill=False, scale=1, linewidth=1, fontsize=1): std::stringstream paramStr; - paramStr << ",allOn=" << (AllOn.getValue() ? "True" : "False") - << ",renderMode=" << RenderMode.getValue() - << ",showHidden=" << (ShowHidden.getValue() ? "True" : "False") - << ",showFill=" << (ShowFill.getValue() ? "True" : "False") - << ",scale=" << getScale() - << ",linewidth=" << LineWidth.getValue() - << ",fontsize=" << FontSize.getValue() - << ",techdraw=True" - << ",rotation=" << Rotation.getValue() - << ",fillSpaces=" << (FillSpaces.getValue() ? "True" : "False") - << ",cutlinewidth=" << CutLineWidth.getValue() - << ",joinArch=" << (JoinArch.getValue() ? "True" : "False"); + paramStr << ", allOn=" << (AllOn.getValue() ? "True" : "False") + << ", renderMode=" << RenderMode.getValue() + << ", showHidden=" << (ShowHidden.getValue() ? "True" : "False") + << ", showFill=" << (ShowFill.getValue() ? "True" : "False") + << ", scale=" << getScale() + << ", linewidth=" << LineWidth.getValue() + << ", fontsize=" << FontSize.getValue() + << ", techdraw=True" + << ", rotation=" << Rotation.getValue() + << ", fillSpaces=" << (FillSpaces.getValue() ? "True" : "False") + << ", cutlinewidth=" << CutLineWidth.getValue() + << ", joinArch=" << (JoinArch.getValue() ? "True" : "False"); Base::Interpreter().runString("import ArchSectionPlane"); Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)", - SourceName.c_str(),paramStr.str().c_str()); + SourceName.c_str(), paramStr.str().c_str()); Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'", - FeatName.c_str(),svgHead.c_str(),svgTail.c_str()); + FeatName.c_str(), svgHead.c_str(), svgTail.c_str()); } overrideKeepUpdated(false); return DrawView::execute(); diff --git a/src/Mod/TechDraw/App/DrawViewArch.h b/src/Mod/TechDraw/App/DrawViewArch.h index 5ed2198cc2..1b13275cf7 100644 --- a/src/Mod/TechDraw/App/DrawViewArch.h +++ b/src/Mod/TechDraw/App/DrawViewArch.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewArch_h_ -#define _DrawViewArch_h_ +#ifndef DrawViewArch_h_ +#define DrawViewArch_h_ #include @@ -42,11 +42,11 @@ class TechDrawExport DrawViewArch : public TechDraw::DrawViewSymbol public: /// Constructor DrawViewArch(); - ~DrawViewArch() override; + ~DrawViewArch() = default; App::PropertyLink Source; App::PropertyBool AllOn; - App::PropertyEnumeration RenderMode; // "Wireframe","Solid" + App::PropertyEnumeration RenderMode; // "Wireframe", "Solid" App::PropertyBool FillSpaces; App::PropertyBool ShowHidden; App::PropertyBool ShowFill; diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.cpp b/src/Mod/TechDraw/App/DrawViewBalloon.cpp index 811ec1703f..094078c769 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.cpp +++ b/src/Mod/TechDraw/App/DrawViewBalloon.cpp @@ -71,7 +71,7 @@ App::PropertyFloatConstraint::Constraints DrawViewBalloon::SymbolScaleRange = { // DrawViewBalloon //=========================================================================== // Balloon coordinates are relative to the position of the SourceView -// X,Y is the center of the balloon bubble +// X, Y is the center of the balloon bubble // OriginX, OriginY is the tip of the arrow // these are in unscaled SourceView coordinates // Note that if the SourceView coordinate system changes @@ -100,7 +100,7 @@ DrawViewBalloon::DrawViewBalloon() EndType.setEnums(ArrowPropEnum::ArrowTypeEnums); ADD_PROPERTY_TYPE(EndType, (prefEnd()), "", (App::PropertyType)(App::Prop_None), "End symbol for the balloon line"); - ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None),"End symbol scale factor"); + ADD_PROPERTY_TYPE(EndTypeScale, (1.0), "", (App::PropertyType)(App::Prop_None), "End symbol scale factor"); EndTypeScale.setConstraints(&SymbolScaleRange); BubbleShape.setEnums(balloonTypeEnums); @@ -115,8 +115,8 @@ DrawViewBalloon::DrawViewBalloon() "Distance from symbol to leader kink"); SourceView.setScope(App::LinkScope::Global); - Rotation.setStatus(App::Property::Hidden,true); - Caption.setStatus(App::Property::Hidden,true); + Rotation.setStatus(App::Property::Hidden, true); + Caption.setStatus(App::Property::Hidden, true); } DrawViewBalloon::~DrawViewBalloon() @@ -168,13 +168,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c DrawView::handleChangedPropertyType(reader, TypeName, prop); // property OriginX had the App::PropertyFloat and was changed to App::PropertyDistance - if ( (prop == &OriginX) && + if ( (prop == &OriginX) && (strcmp(TypeName, "App::PropertyFloat") == 0) ) { App::PropertyFloat OriginXProperty; // restore the PropertyFloat to be able to set its value OriginXProperty.Restore(reader); OriginX.setValue(OriginXProperty.getValue()); - } else if ( (prop == &OriginX) && + } else if ( (prop == &OriginX) && (strcmp(TypeName, "App::PropertyLength") == 0) ) { App::PropertyLength OriginXProperty; // restore the PropertyFloat to be able to set its value @@ -182,13 +182,13 @@ void DrawViewBalloon::handleChangedPropertyType(Base::XMLReader &reader, const c OriginX.setValue(OriginXProperty.getValue()); // property OriginY had the App::PropertyFloat and was changed to App::PropertyDistance - } else if ( (prop == &OriginY) && + } else if ( (prop == &OriginY) && (strcmp(TypeName, "App::PropertyFloat") == 0) ) { App::PropertyFloat OriginYProperty; // restore the PropertyFloat to be able to set its value OriginYProperty.Restore(reader); OriginY.setValue(OriginYProperty.getValue()); - } else if ( (prop == &OriginY) && + } else if ( (prop == &OriginY) && (strcmp(TypeName, "App::PropertyLength") == 0) ) { App::PropertyLength OriginYProperty; // restore the PropertyLength to be able to set its value @@ -298,7 +298,7 @@ PyObject *DrawViewBalloon::getPyObject(void) { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewBalloonPy(this),true); + PythonObject = Py::Object(new DrawViewBalloonPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawViewBalloon.h b/src/Mod/TechDraw/App/DrawViewBalloon.h index 7f2415f6c3..d0c84dab22 100644 --- a/src/Mod/TechDraw/App/DrawViewBalloon.h +++ b/src/Mod/TechDraw/App/DrawViewBalloon.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawViewBalloon_h_ -#define _TechDraw_DrawViewBalloon_h_ +#ifndef TechDraw_DrawViewBalloon_h_ +#define TechDraw_DrawViewBalloon_h_ #include @@ -90,10 +90,10 @@ public: protected: void onChanged(const App::Property* prop) override; void handleChangedPropertyType(Base::XMLReader &reader, - const char *TypeName, + const char *TypeName, App::Property * prop) override; void handleChangedPropertyName(Base::XMLReader &reader, - const char * TypeName, + const char * TypeName, const char *PropName) override; private: diff --git a/src/Mod/TechDraw/App/DrawViewClip.cpp b/src/Mod/TechDraw/App/DrawViewClip.cpp index 3a25ef9393..dbe70f735b 100644 --- a/src/Mod/TechDraw/App/DrawViewClip.cpp +++ b/src/Mod/TechDraw/App/DrawViewClip.cpp @@ -50,21 +50,17 @@ DrawViewClip::DrawViewClip() static const char *group = "Clip Group"; //App::PropertyType hidden = (App::PropertyType)(App::Prop_Hidden); - ADD_PROPERTY_TYPE(Height ,(100),group,App::Prop_None,"The height of the view area of this clip"); - ADD_PROPERTY_TYPE(Width ,(100),group,App::Prop_None,"The width of the view area of this clip"); - ADD_PROPERTY_TYPE(ShowFrame ,(0) ,group,App::Prop_None,"Specifies if the clip frame appears on the page or not"); - ADD_PROPERTY_TYPE(Views ,(nullptr) ,group,App::Prop_None,"The Views in this Clip group"); + ADD_PROPERTY_TYPE(Height ,(100), group, App::Prop_None, "The height of the view area of this clip"); + ADD_PROPERTY_TYPE(Width ,(100), group, App::Prop_None, "The width of the view area of this clip"); + ADD_PROPERTY_TYPE(ShowFrame ,(0) ,group, App::Prop_None, "Specifies if the clip frame appears on the page or not"); + ADD_PROPERTY_TYPE(Views ,(nullptr) ,group, App::Prop_None, "The Views in this Clip group"); Views.setScope(App::LinkScope::Global); // hide N/A properties - ScaleType.setStatus(App::Property::ReadOnly,true); - ScaleType.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::ReadOnly,true); - Scale.setStatus(App::Property::Hidden,true); -} - -DrawViewClip::~DrawViewClip() -{ + ScaleType.setStatus(App::Property::ReadOnly, true); + ScaleType.setStatus(App::Property::Hidden, true); + Scale.setStatus(App::Property::ReadOnly, true); + Scale.setStatus(App::Property::Hidden, true); } void DrawViewClip::onChanged(const App::Property* prop) @@ -164,7 +160,7 @@ PyObject *DrawViewClip::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewClipPy(this),true); + PythonObject = Py::Object(new DrawViewClipPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawViewClip.h b/src/Mod/TechDraw/App/DrawViewClip.h index 0699cf8f2d..79fc0a168d 100644 --- a/src/Mod/TechDraw/App/DrawViewClip.h +++ b/src/Mod/TechDraw/App/DrawViewClip.h @@ -21,8 +21,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewClip_h_ -#define _DrawViewClip_h_ +#ifndef DrawViewClip_h_ +#define DrawViewClip_h_ #include @@ -44,7 +44,7 @@ class TechDrawExport DrawViewClip: public TechDraw::DrawView public: /// Constructor DrawViewClip(); - ~DrawViewClip() override; + ~DrawViewClip() = default; App::PropertyLength Width; App::PropertyLength Height; @@ -70,7 +70,7 @@ public: std::vector getChildViewNames(); bool isViewInClip(App::DocumentObject* view); - QRectF getRect() const override { return QRectF(0,0,Width.getValue(),Height.getValue()); } + QRectF getRect() const override { return { 0, 0, Width.getValue(), Height.getValue() }; } protected: diff --git a/src/Mod/TechDraw/App/DrawViewClipPyImp.cpp b/src/Mod/TechDraw/App/DrawViewClipPyImp.cpp index a270f43203..1338e1075a 100644 --- a/src/Mod/TechDraw/App/DrawViewClipPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewClipPyImp.cpp @@ -44,14 +44,14 @@ std::string DrawViewClipPy::representation() const PyObject* DrawViewClipPy::addView(PyObject* args) { //this implements iRC = pyClip.addView(pyView) -or- - //doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + //doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { Base::Console().Error("Error: DrawViewClipPy::addView - Bad Arg - not DocumentObject\n"); return nullptr; //TODO: sb PyErr?? - //PyErr_SetString(PyExc_TypeError,"addView expects a DrawView"); + //PyErr_SetString(PyExc_TypeError, "addView expects a DrawView"); //return -1; } @@ -68,14 +68,14 @@ PyObject* DrawViewClipPy::addView(PyObject* args) PyObject* DrawViewClipPy::removeView(PyObject* args) { //this implements iRC = pyClip.removeView(pyView) -or- - //doCommand(Doc,"App.activeDocument().%s.removeView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + //doCommand(Doc, "App.activeDocument().%s.removeView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); PyObject *pcDocObj; if (!PyArg_ParseTuple(args, "O!", &(App::DocumentObjectPy::Type), &pcDocObj)) { Base::Console().Error("Error: DrawViewClipPy::removeView - Bad Arg - not DocumentObject\n"); return nullptr; //TODO: sb PyErr?? - //PyErr_SetString(PyExc_TypeError,"removeView expects a DrawView"); + //PyErr_SetString(PyExc_TypeError, "removeView expects a DrawView"); //return -1; } diff --git a/src/Mod/TechDraw/App/DrawViewCollection.cpp b/src/Mod/TechDraw/App/DrawViewCollection.cpp index f32b2a00da..17e6c82efa 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.cpp +++ b/src/Mod/TechDraw/App/DrawViewCollection.cpp @@ -47,7 +47,7 @@ DrawViewCollection::DrawViewCollection() { nowUnsetting = false; static const char *group = "Collection"; - ADD_PROPERTY_TYPE(Views ,(nullptr), group, App::Prop_None,"Collection Views"); + ADD_PROPERTY_TYPE(Views ,(nullptr), group, App::Prop_None, "Collection Views"); Views.setScope(App::LinkScope::Global); } @@ -196,7 +196,7 @@ QRectF DrawViewCollection::getRect() const throw Base::ValueError("DrawViewCollection::getRect bad View\n"); } - result = result.united(view->getRect().translated(view->X.getValue(),view->Y.getValue())); + result = result.united(view->getRect().translated(view->X.getValue(), view->Y.getValue())); } - return QRectF(0,0,getScale() * result.width(),getScale() * result.height()); + return { 0, 0, getScale() * result.width(), getScale() * result.height()}; } diff --git a/src/Mod/TechDraw/App/DrawViewCollection.h b/src/Mod/TechDraw/App/DrawViewCollection.h index 8d754b0f7e..3fb1d8ac23 100644 --- a/src/Mod/TechDraw/App/DrawViewCollection.h +++ b/src/Mod/TechDraw/App/DrawViewCollection.h @@ -21,8 +21,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_FEATUREVIEWCOLLECTION_h_ -#define _TECHDRAW_FEATUREVIEWCOLLECTION_h_ +#ifndef TECHDRAW_FEATUREVIEWCOLLECTION_h_ +#define TECHDRAW_FEATUREVIEWCOLLECTION_h_ #include @@ -73,4 +73,4 @@ protected: } //namespace TechDraw -#endif // _TECHDRAW_FEATUREVIEWCOLLECTION_h_ +#endif // TECHDRAW_FEATUREVIEWCOLLECTION_h_ diff --git a/src/Mod/TechDraw/App/DrawViewDetail.cpp b/src/Mod/TechDraw/App/DrawViewDetail.cpp index 70e9fd76a2..d77b1172cf 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.cpp +++ b/src/Mod/TechDraw/App/DrawViewDetail.cpp @@ -90,18 +90,18 @@ DrawViewDetail::DrawViewDetail() : { static const char *dgroup = "Detail"; - ADD_PROPERTY_TYPE(BaseView ,(nullptr),dgroup,App::Prop_None,"2D View source for this Section"); + ADD_PROPERTY_TYPE(BaseView ,(nullptr), dgroup, App::Prop_None, "2D View source for this Section"); BaseView.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(AnchorPoint ,(0,0,0) ,dgroup,App::Prop_None,"Location of detail in BaseView"); - ADD_PROPERTY_TYPE(Radius,(10.0),dgroup, App::Prop_None, "Size of detail area"); - ADD_PROPERTY_TYPE(Reference ,("1"),dgroup,App::Prop_None,"An identifier for this detail"); + ADD_PROPERTY_TYPE(AnchorPoint ,(0, 0,0) ,dgroup, App::Prop_None, "Location of detail in BaseView"); + ADD_PROPERTY_TYPE(Radius, (10.0), dgroup, App::Prop_None, "Size of detail area"); + ADD_PROPERTY_TYPE(Reference ,("1"), dgroup, App::Prop_None, "An identifier for this detail"); getParameters(); m_fudge = 1.01; //hide Properties not relevant to DVDetail - Direction.setStatus(App::Property::ReadOnly,true); //Should be same as BaseView - Rotation.setStatus(App::Property::ReadOnly,true); //same as BaseView + Direction.setStatus(App::Property::ReadOnly, true); //Should be same as BaseView + Rotation.setStatus(App::Property::ReadOnly, true); //same as BaseView ScaleType.setValue("Custom"); //dvd uses scale from BaseView } @@ -171,7 +171,7 @@ App::DocumentObjectExecReturn *DrawViewDetail::execute() //this can only happen via scripting? return DrawView::execute(); } - + DrawViewPart* dvp = static_cast(baseObj); DrawViewSection* dvs = nullptr; TopoDS_Shape shape; @@ -248,7 +248,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, gp_Pnt gpCenter = TechDraw::findCentroid(copyShape, dirDetail); - Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(),gpCenter.Y(),gpCenter.Z()); + Base::Vector3d shapeCenter = Base::Vector3d(gpCenter.X(), gpCenter.Y(), gpCenter.Z()); m_saveCentroid = shapeCenter; //centroid of original shape if (!dvs) { @@ -272,8 +272,8 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, Base::Vector3d toolPlaneOrigin = anchor + dirDetail * diag * -1.0; //center tool about anchor double extrudeLength = 2.0 * toolPlaneOrigin.Length(); - gp_Pnt gpnt(toolPlaneOrigin.x,toolPlaneOrigin.y,toolPlaneOrigin.z); - gp_Dir gdir(dirDetail.x,dirDetail.y,dirDetail.z); + gp_Pnt gpnt(toolPlaneOrigin.x, toolPlaneOrigin.y, toolPlaneOrigin.z); + gp_Dir gdir(dirDetail.x, dirDetail.y, dirDetail.z); TopoDS_Face extrusionFace; Base::Vector3d extrudeVec = dirDetail * extrudeLength; @@ -281,7 +281,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, TopoDS_Shape tool; if (Preferences::mattingStyle()) { //square mat - gp_Pln gpln(gpnt,gdir); + gp_Pln gpln(gpnt, gdir); BRepBuilderAPI_MakeFace mkFace(gpln, -radius, radius, -radius, radius); extrusionFace = mkFace.Face(); if(extrusionFace.IsNull()) { @@ -315,7 +315,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, for (; expl.More(); expl.Next()) { const TopoDS_Solid& s = TopoDS::Solid(expl.Current()); - BRepAlgoAPI_Common mkCommon(s,tool); + BRepAlgoAPI_Common mkCommon(s, tool); if (!mkCommon.IsDone()) { continue; } @@ -325,7 +325,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, //this might be overkill for piecewise algo //Did we get at least 1 solid? TopExp_Explorer xp; - xp.Init(mkCommon.Shape(),TopAbs_SOLID); + xp.Init(mkCommon.Shape(), TopAbs_SOLID); if (xp.More() != Standard_True) { continue; } @@ -338,7 +338,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, for (; expl.More(); expl.Next()) { const TopoDS_Shell& s = TopoDS::Shell(expl.Current()); - BRepAlgoAPI_Common mkCommon(s,tool); + BRepAlgoAPI_Common mkCommon(s, tool); if (!mkCommon.IsDone()) { continue; } @@ -348,7 +348,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, //this might be overkill for piecewise algo //Did we get at least 1 shell? TopExp_Explorer xp; - xp.Init(mkCommon.Shape(),TopAbs_SHELL); + xp.Init(mkCommon.Shape(), TopAbs_SHELL); if (xp.More() != Standard_True) { continue; } @@ -395,10 +395,10 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, getScale()); } - Base::Vector3d stdOrg(0.0,0.0,0.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); m_viewAxis = dvp->getProjectionCS(stdOrg); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { m_scaledShape = TechDraw::rotateShape(m_scaledShape, m_viewAxis, Rotation.getValue()); @@ -406,7 +406,7 @@ void DrawViewDetail::makeDetailShape(TopoDS_Shape& shape, } //end try block catch (Standard_Failure& e1) { - Base::Console().Message("DVD::makeDetailShape - failed to create detail %s - %s **\n",getNameInDocument(),e1.GetMessageString()); + Base::Console().Message("DVD::makeDetailShape - failed to create detail %s - %s **\n", getNameInDocument(), e1.GetMessageString()); return; } @@ -491,7 +491,7 @@ bool DrawViewDetail::debugDetail() const Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/debug"); - return hGrp->GetBool("debugDetail",false); + return hGrp->GetBool("debugDetail", false); } void DrawViewDetail::unsetupObject() diff --git a/src/Mod/TechDraw/App/DrawViewDetail.h b/src/Mod/TechDraw/App/DrawViewDetail.h index b1fad36f5e..46ac8dc510 100644 --- a/src/Mod/TechDraw/App/DrawViewDetail.h +++ b/src/Mod/TechDraw/App/DrawViewDetail.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewDetail_h_ -#define _DrawViewDetail_h_ +#ifndef DrawViewDetail_h_ +#define DrawViewDetail_h_ #include diff --git a/src/Mod/TechDraw/App/DrawViewDimExtent.cpp b/src/Mod/TechDraw/App/DrawViewDimExtent.cpp index e8c3c1967a..2e131f730b 100644 --- a/src/Mod/TechDraw/App/DrawViewDimExtent.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimExtent.cpp @@ -49,8 +49,6 @@ #include "DrawViewPart.h" #include "DrawViewDimExtent.h" #include "DrawDimHelper.h" -#include "DrawUtil.h" -#include "LineGroup.h" #include // generated from DrawViewDimExtentPy.xml @@ -68,23 +66,19 @@ DrawViewDimExtent::DrawViewDimExtent(void) //Cosmetic End points are stored in DVD::References2d App::PropertyLinkSubList Source3d; //Part::Feature & SubElements TBI - ADD_PROPERTY_TYPE(Source,(nullptr,nullptr),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension"); + ADD_PROPERTY_TYPE(Source, (nullptr, nullptr), "", (App::PropertyType)(App::Prop_Output), "View (Edges) to dimension"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(Source3d,(nullptr,nullptr),"",(App::PropertyType)(App::Prop_Output),"View (Edges) to dimension"); //TBI + ADD_PROPERTY_TYPE(Source3d, (nullptr, nullptr), "", (App::PropertyType)(App::Prop_Output), "View (Edges) to dimension"); //TBI Source3d.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(DirExtent ,(0),"",App::Prop_Output,"Horizontal / Vertical"); + ADD_PROPERTY_TYPE(DirExtent ,(0), "", App::Prop_Output, "Horizontal / Vertical"); - ADD_PROPERTY_TYPE(CosmeticTags ,(""),"",App::Prop_Output,"Id of cosmetic endpoints"); + ADD_PROPERTY_TYPE(CosmeticTags ,(""), "", App::Prop_Output, "Id of cosmetic endpoints"); //hide the properties the user can't edit in the property editor - Source3d.setStatus(App::Property::Hidden,true); //TBI + Source3d.setStatus(App::Property::Hidden, true); //TBI } -DrawViewDimExtent::~DrawViewDimExtent() -{ -} - void DrawViewDimExtent::onChanged(const App::Property* prop) { if (!isRestoring()) { @@ -173,7 +167,7 @@ std::vector DrawViewDimExtent::getSubNames(void) pointPair DrawViewDimExtent::getPointsTwoVerts() { -// Base::Console().Message("DVDE::getPointsTwoVerts() - %s\n",getNameInDocument()); +// Base::Console().Message("DVDE::getPointsTwoVerts() - %s\n", getNameInDocument()); pointPair errorValue( Base::Vector3d(0.0, 0.0, 0.0), Base::Vector3d(0.0, 0.0, 0.0) @@ -188,7 +182,7 @@ pointPair DrawViewDimExtent::getPointsTwoVerts() if (cTags.empty()) { return errorValue; } - + TechDraw::VertexPtr v0 = dvp->getProjVertexByCosTag(cTags[0]); TechDraw::VertexPtr v1 = dvp->getProjVertexByCosTag(cTags[1]); if (!v0 || !v1) @@ -200,7 +194,7 @@ pointPair DrawViewDimExtent::getPointsTwoVerts() //! validate 2D references - only checks if the target exists bool DrawViewDimExtent::checkReferences2D() const { -// Base::Console().Message("DVDE::checkReFerences2d() - %s\n",getNameInDocument()); +// Base::Console().Message("DVDE::checkReFerences2d() - %s\n", getNameInDocument()); TechDraw::DrawViewPart* dvp = getViewPart(); if (!dvp) { return false; @@ -210,7 +204,7 @@ bool DrawViewDimExtent::checkReferences2D() const if (cTags.empty()) { return false; } - + CosmeticVertex* cv0 = dvp->getCosmeticVertex(cTags[0]); CosmeticVertex* cv1 = dvp->getCosmeticVertex(cTags[1]); if (!cv0 || !cv1) @@ -238,7 +232,7 @@ PyObject *DrawViewDimExtent::getPyObject(void) { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewDimExtentPy(this),true); + PythonObject = Py::Object(new DrawViewDimExtentPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawViewDimExtent.h b/src/Mod/TechDraw/App/DrawViewDimExtent.h index 98a139eea0..a36038e0e8 100644 --- a/src/Mod/TechDraw/App/DrawViewDimExtent.h +++ b/src/Mod/TechDraw/App/DrawViewDimExtent.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawViewDimExtent_h_ -#define _TechDraw_DrawViewDimExtent_h_ +#ifndef TechDraw_DrawViewDimExtent_h_ +#define TechDraw_DrawViewDimExtent_h_ #include @@ -42,7 +42,7 @@ class TechDrawExport DrawViewDimExtent : public TechDraw::DrawViewDimension public: /// Constructor DrawViewDimExtent(); - ~DrawViewDimExtent() override; + ~DrawViewDimExtent() = default; App::PropertyLinkSubList Source; //DrawViewPart & SubElements(Edges) //Cosmetic End points are stored in DVD::References2d diff --git a/src/Mod/TechDraw/App/DrawViewDimension.cpp b/src/Mod/TechDraw/App/DrawViewDimension.cpp index c309cfa90f..209c825590 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.cpp +++ b/src/Mod/TechDraw/App/DrawViewDimension.cpp @@ -105,22 +105,22 @@ static const App::PropertyQuantityConstraint::Constraints PositiveConstraint = { DrawViewDimension::DrawViewDimension() { - ADD_PROPERTY_TYPE(References2D, (nullptr,nullptr), "", (App::Prop_None), "Projected Geometry References"); + ADD_PROPERTY_TYPE(References2D, (nullptr, nullptr), "", (App::Prop_None), "Projected Geometry References"); References2D.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(References3D, (nullptr,nullptr), "", (App::Prop_None), "3D Geometry References"); + ADD_PROPERTY_TYPE(References3D, (nullptr, nullptr), "", (App::Prop_None), "3D Geometry References"); References3D.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output,"Dimension format"); + ADD_PROPERTY_TYPE(FormatSpec, (getDefaultFormatSpec()), "Format", App::Prop_Output, "Dimension format"); ADD_PROPERTY_TYPE(FormatSpecOverTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension overtolerance format"); ADD_PROPERTY_TYPE(FormatSpecUnderTolerance, (getDefaultFormatSpec(true)), "Format", App::Prop_Output, "Dimension undertolerance format"); - ADD_PROPERTY_TYPE(Arbitrary,(false), "Format", App::Prop_Output, "Value overridden by user"); + ADD_PROPERTY_TYPE(Arbitrary, (false), "Format", App::Prop_Output, "Value overridden by user"); ADD_PROPERTY_TYPE(ArbitraryTolerances, (false), "Format", App::Prop_Output, "Tolerance values overridden by user"); Type.setEnums(TypeEnums); //dimension type: length, radius etc ADD_PROPERTY(Type, ((long)0)); MeasureType.setEnums(MeasureTypeEnums); ADD_PROPERTY(MeasureType, ((long)1)); //Projected (or True) measurement - ADD_PROPERTY_TYPE(TheoreticalExact,(false), "", App::Prop_Output, "If theoretical exact (basic) dimension"); + ADD_PROPERTY_TYPE(TheoreticalExact, (false), "", App::Prop_Output, "If theoretical exact (basic) dimension"); ADD_PROPERTY_TYPE(EqualTolerance, (true), "", App::Prop_Output, "If over- and undertolerance are equal"); ADD_PROPERTY_TYPE(OverTolerance, (0.0), "", App::Prop_Output, "Overtolerance value\nIf 'Equal Tolerance' is true this is also\nthe negated value for 'Under Tolerance'"); @@ -131,9 +131,9 @@ DrawViewDimension::DrawViewDimension() UnderTolerance.setConstraints(&ToleranceConstraint); ADD_PROPERTY_TYPE(Inverted, (false), "", App::Prop_Output, "The dimensional value is displayed inverted"); - ADD_PROPERTY_TYPE(AngleOverride,(false), "Override", App::Prop_Output, "User specified angles"); - ADD_PROPERTY_TYPE(LineAngle,(0.0), "Override", App::Prop_Output, "Dimension line angle"); - ADD_PROPERTY_TYPE(ExtensionAngle,(0.0), "Override", App::Prop_Output, "Extension line angle"); + ADD_PROPERTY_TYPE(AngleOverride, (false), "Override", App::Prop_Output, "User specified angles"); + ADD_PROPERTY_TYPE(LineAngle, (0.0), "Override", App::Prop_Output, "Dimension line angle"); + ADD_PROPERTY_TYPE(ExtensionAngle, (0.0), "Override", App::Prop_Output, "Extension line angle"); // hide the DrawView properties that don't apply to Dimensions ScaleType.setStatus(App::Property::ReadOnly, true); @@ -150,7 +150,7 @@ DrawViewDimension::DrawViewDimension() FormatSpecUnderTolerance.setStatus(App::Property::ReadOnly, true); measurement = new Measure::Measurement(); - //TODO: should have better initial datumLabel position than (0,0) in the DVP?? something closer to the object being measured? + //TODO: should have better initial datumLabel position than (0, 0) in the DVP?? something closer to the object being measured? //initialize the descriptive geometry. //TODO: should this be more like DVP with a "geometry object"? @@ -168,26 +168,26 @@ DrawViewDimension::~DrawViewDimension() void DrawViewDimension::resetLinear() { - m_linearPoints.first = Base::Vector3d(0,0,0); - m_linearPoints.second = Base::Vector3d(0,0,0); + m_linearPoints.first = Base::Vector3d(0, 0,0); + m_linearPoints.second = Base::Vector3d(0, 0,0); } void DrawViewDimension::resetAngular() { - m_anglePoints.ends.first = Base::Vector3d(0,0,0); - m_anglePoints.ends.second = Base::Vector3d(0,0,0); - m_anglePoints.vertex = Base::Vector3d(0,0,0); + m_anglePoints.ends.first = Base::Vector3d(0, 0,0); + m_anglePoints.ends.second = Base::Vector3d(0, 0,0); + m_anglePoints.vertex = Base::Vector3d(0, 0,0); } void DrawViewDimension::resetArc() { m_arcPoints.isArc = false; - m_arcPoints.center = Base::Vector3d(0,0,0); - m_arcPoints.onCurve.first = Base::Vector3d(0,0,0); - m_arcPoints.onCurve.second = Base::Vector3d(0,0,0); - m_arcPoints.arcEnds.first = Base::Vector3d(0,0,0); - m_arcPoints.arcEnds.second = Base::Vector3d(0,0,0); - m_arcPoints.midArc = Base::Vector3d(0,0,0); + m_arcPoints.center = Base::Vector3d(0, 0,0); + m_arcPoints.onCurve.first = Base::Vector3d(0, 0,0); + m_arcPoints.onCurve.second = Base::Vector3d(0, 0,0); + m_arcPoints.arcEnds.first = Base::Vector3d(0, 0,0); + m_arcPoints.arcEnds.second = Base::Vector3d(0, 0,0); + m_arcPoints.midArc = Base::Vector3d(0, 0,0); m_arcPoints.arcCW = false; } @@ -268,7 +268,7 @@ void DrawViewDimension::onChanged(const App::Property* prop) } } requestPaint(); - } + } else if (prop == &OverTolerance) { // if EqualTolerance set negated overtolerance for untertolerance if (EqualTolerance.getValue()) { @@ -440,26 +440,26 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx); TechDraw::CirclePtr circle; arcPoints pts; - pts.center = Base::Vector3d(0.0,0.0,0.0); + pts.center = Base::Vector3d(0.0, 0.0, 0.0); pts.radius = 0.0; if ( (base && base->geomType == TechDraw::GeomType::CIRCLE) || (base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) { circle = std::static_pointer_cast (base); - pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0); + pts.center = Base::Vector3d(circle->center.x, circle->center.y, 0.0); pts.radius = circle->radius; if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) { // TechDraw::AOCPtr aoc = std::static_pointer_cast (circle); TechDraw::AOCPtr aoc = std::static_pointer_cast (base); pts.isArc = true; - pts.onCurve.first = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0); - pts.midArc = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0); - pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x,aoc->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x,aoc->endPnt.y,0.0); + pts.onCurve.first = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0); + pts.midArc = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0); + pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x, aoc->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x, aoc->endPnt.y, 0.0); pts.arcCW = aoc->cw; } else { pts.isArc = false; - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * circle->radius; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * circle->radius; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * circle->radius; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * circle->radius; //arbitrary point on edge } } else if ((base && base->geomType == TechDraw::GeomType::ELLIPSE) || (base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE)) { @@ -474,8 +474,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() 0.0); pts.radius = rAvg; pts.isArc = false; - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge } else { TechDraw::AOEPtr aoe = std::static_pointer_cast (base); double r1 = aoe->minor; @@ -486,41 +486,41 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() aoe->center.y, 0.0); pts.radius = rAvg; - pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x,aoe->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x,aoe->endPnt.y,0.0); - pts.midArc = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0); + pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x, aoe->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x, aoe->endPnt.y, 0.0); + pts.midArc = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0); pts.arcCW = aoe->cw; - pts.onCurve.first = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0); - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge + pts.onCurve.first = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0); + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge } } else if (base && base->geomType == TechDraw::GeomType::BSPLINE) { TechDraw::BSplinePtr spline; spline = std::static_pointer_cast (base); if (spline->isCircle()) { - bool circ,arc; + bool circ, arc; double rad; Base::Vector3d center; - spline->getCircleParms(circ,rad,center,arc); - pts.center = Base::Vector3d(center.x,center.y,0.0); + spline->getCircleParms(circ, rad, center, arc); + pts.center = Base::Vector3d(center.x, center.y, 0.0); pts.radius = rad; - pts.arcEnds.first = Base::Vector3d(spline->startPnt.x,spline->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(spline->endPnt.x,spline->endPnt.y,0.0); - pts.midArc = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0); + pts.arcEnds.first = Base::Vector3d(spline->startPnt.x, spline->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(spline->endPnt.x, spline->endPnt.y, 0.0); + pts.midArc = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0); pts.isArc = arc; pts.arcCW = spline->cw; if (arc) { - pts.onCurve.first = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0); + pts.onCurve.first = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0); } else { - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rad; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rad; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rad; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rad; //arbitrary point on edge } } else { //fubar - can't have non-circular spline as target of Radius dimension - Base::Console().Error("Dimension %s refers to invalid BSpline\n",getNameInDocument()); + Base::Console().Error("Dimension %s refers to invalid BSpline\n", getNameInDocument()); return App::DocumentObject::StdReturn; } } else { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } m_arcPoints = pts; @@ -530,25 +530,25 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx); TechDraw::CirclePtr circle; arcPoints pts; - pts.center = Base::Vector3d(0.0,0.0,0.0); + pts.center = Base::Vector3d(0.0, 0.0, 0.0); pts.radius = 0.0; if ((base && base->geomType == TechDraw::GeomType::CIRCLE) || (base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE)) { circle = std::static_pointer_cast (base); - pts.center = Base::Vector3d(circle->center.x,circle->center.y,0.0); + pts.center = Base::Vector3d(circle->center.x, circle->center.y, 0.0); pts.radius = circle->radius; if (base->geomType == TechDraw::GeomType::ARCOFCIRCLE) { TechDraw::AOCPtr aoc = std::static_pointer_cast (circle); pts.isArc = true; - pts.onCurve.first = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0); - pts.midArc = Base::Vector3d(aoc->midPnt.x,aoc->midPnt.y,0.0); - pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x,aoc->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x,aoc->endPnt.y,0.0); + pts.onCurve.first = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0); + pts.midArc = Base::Vector3d(aoc->midPnt.x, aoc->midPnt.y, 0.0); + pts.arcEnds.first = Base::Vector3d(aoc->startPnt.x, aoc->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(aoc->endPnt.x, aoc->endPnt.y, 0.0); pts.arcCW = aoc->cw; } else { pts.isArc = false; - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * circle->radius; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * circle->radius; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * circle->radius; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * circle->radius; //arbitrary point on edge } } else if ( (base && base->geomType == TechDraw::GeomType::ELLIPSE) || (base && base->geomType == TechDraw::GeomType::ARCOFELLIPSE) ) { @@ -562,8 +562,8 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() 0.0); pts.radius = rAvg; pts.isArc = false; - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge } else { TechDraw::AOEPtr aoe = std::static_pointer_cast (base); double r1 = aoe->minor; @@ -574,47 +574,47 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() aoe->center.y, 0.0); pts.radius = rAvg; - pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x,aoe->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x,aoe->endPnt.y,0.0); - pts.midArc = Base::Vector3d(aoe->midPnt.x,aoe->midPnt.y,0.0); + pts.arcEnds.first = Base::Vector3d(aoe->startPnt.x, aoe->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(aoe->endPnt.x, aoe->endPnt.y, 0.0); + pts.midArc = Base::Vector3d(aoe->midPnt.x, aoe->midPnt.y, 0.0); pts.arcCW = aoe->cw; - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rAvg; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rAvg; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rAvg; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rAvg; //arbitrary point on edge } } else if (base && base->geomType == TechDraw::GeomType::BSPLINE) { TechDraw::BSplinePtr spline = std::static_pointer_cast (base); if (spline->isCircle()) { - bool circ,arc; + bool circ, arc; double rad; Base::Vector3d center; - spline->getCircleParms(circ,rad,center,arc); - pts.center = Base::Vector3d(center.x,center.y,0.0); + spline->getCircleParms(circ, rad, center, arc); + pts.center = Base::Vector3d(center.x, center.y, 0.0); pts.radius = rad; - pts.arcEnds.first = Base::Vector3d(spline->startPnt.x,spline->startPnt.y,0.0); - pts.arcEnds.second = Base::Vector3d(spline->endPnt.x,spline->endPnt.y,0.0); - pts.midArc = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0); + pts.arcEnds.first = Base::Vector3d(spline->startPnt.x, spline->startPnt.y, 0.0); + pts.arcEnds.second = Base::Vector3d(spline->endPnt.x, spline->endPnt.y, 0.0); + pts.midArc = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0); pts.isArc = arc; pts.arcCW = spline->cw; if (arc) { - pts.onCurve.first = Base::Vector3d(spline->midPnt.x,spline->midPnt.y,0.0); + pts.onCurve.first = Base::Vector3d(spline->midPnt.x, spline->midPnt.y, 0.0); } else { - pts.onCurve.first = pts.center + Base::Vector3d(1,0,0) * rad; //arbitrary point on edge - pts.onCurve.second = pts.center + Base::Vector3d(-1,0,0) * rad; //arbitrary point on edge + pts.onCurve.first = pts.center + Base::Vector3d(1, 0,0) * rad; //arbitrary point on edge + pts.onCurve.second = pts.center + Base::Vector3d(-1, 0,0) * rad; //arbitrary point on edge } } else { //fubar - can't have non-circular spline as target of Diameter dimension - Base::Console().Error("%s: can not make a Circle from this BSpline edge\n",getNameInDocument()); + Base::Console().Error("%s: can not make a Circle from this BSpline edge\n", getNameInDocument()); return App::DocumentObject::StdReturn; } } else { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } m_arcPoints = pts; m_hasGeometry = true; } else if (Type.isValue("Angle")){ if (getRefType() != twoEdge) { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } int idx0 = DrawUtil::getIndexFromName(subElements[0]); @@ -626,19 +626,19 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() if (edge0 && edge0->geomType == TechDraw::GeomType::GENERIC) { gen0 = std::static_pointer_cast(edge0); } else { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } if (edge1 && edge1->geomType == TechDraw::GeomType::GENERIC) { gen1 = std::static_pointer_cast(edge1); } else { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } anglePoints pts; Base::Vector3d apex = gen0->apparentInter(gen1); - Base::Vector3d extPoint0,extPoint1; + Base::Vector3d extPoint0, extPoint1; Base::Vector3d farPoint0, farPoint1; //pick the end of gen0 farthest from the apex if ((gen0->getStartPoint() - apex).Length() > @@ -710,7 +710,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() m_hasGeometry = true; } else if (Type.isValue("Angle3Pt")){ if (getRefType() != threeVertex) { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } int idx0 = DrawUtil::getIndexFromName(subElements[0]); @@ -721,7 +721,7 @@ App::DocumentObjectExecReturn *DrawViewDimension::execute() TechDraw::VertexPtr vert1 = getViewPart()->getProjVertexByIndex(idx1); TechDraw::VertexPtr vert2 = getViewPart()->getProjVertexByIndex(idx2); if (!vert0 || !vert1 || !vert2) { - Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n",getNameInDocument()); + Base::Console().Log("Error: DVD - %s - 2D references are corrupt\n", getNameInDocument()); return App::DocumentObject::StdReturn; } @@ -867,7 +867,7 @@ std::string DrawViewDimension::formatValue(qreal value, if (pos != -1) { qUserStringUnits = rxUnits.cap(0); // entire capture - non numerics at end of qUserString } - + // get value in the base unit with default decimals // for the conversion we use the same method as in DlgUnitsCalculator::valueChanged // get the conversion factor for the unit @@ -924,7 +924,7 @@ std::string DrawViewDimension::formatValue(qreal value, } } - + std::string formattedValueString = formattedValue.toStdString(); if (partial == 0) { //full text for multi-value schemas @@ -1177,7 +1177,7 @@ double DrawViewDimension::getDimValue() } else { // Projected Values if (!checkReferences2D()) { - Base::Console().Warning("DVD::getDimValue - %s - 2D references are corrupt (5)\n",getNameInDocument()); + Base::Console().Warning("DVD::getDimValue - %s - 2D references are corrupt (5)\n", getNameInDocument()); return result; } if ( Type.isValue("Distance") || @@ -1227,14 +1227,14 @@ double DrawViewDimension::getDimValue() pointPair DrawViewDimension::getPointsOneEdge() { -// Base::Console().Message("DVD::getPointsOneEdge() - %s\n",getNameInDocument()); +// Base::Console().Message("DVD::getPointsOneEdge() - %s\n", getNameInDocument()); const std::vector &subElements = References2D.getSubValues(); //TODO: Check for straight line Edge? int idx = DrawUtil::getIndexFromName(subElements[0]); TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx); if (!geom || geom->geomType != TechDraw::GeomType::GENERIC) { - Base::Console().Error("Error: DVD - %s - 2D references are corrupt (1)\n",getNameInDocument()); + Base::Console().Error("Error: DVD - %s - 2D references are corrupt (1)\n", getNameInDocument()); return pointPair(); } @@ -1244,7 +1244,7 @@ pointPair DrawViewDimension::getPointsOneEdge() pointPair DrawViewDimension::getPointsTwoEdges() { -// Base::Console().Message("DVD::getPointsTwoEdges() - %s\n",getNameInDocument()); +// Base::Console().Message("DVD::getPointsTwoEdges() - %s\n", getNameInDocument()); pointPair result; const std::vector &subElements = References2D.getSubValues(); @@ -1253,16 +1253,16 @@ pointPair DrawViewDimension::getPointsTwoEdges() TechDraw::BaseGeomPtr geom0 = getViewPart()->getGeomByIndex(idx0); TechDraw::BaseGeomPtr geom1 = getViewPart()->getGeomByIndex(idx1); if (!geom0 || !geom1) { - Base::Console().Error("Error: DVD - %s - 2D references are corrupt (2)\n",getNameInDocument()); + Base::Console().Error("Error: DVD - %s - 2D references are corrupt (2)\n", getNameInDocument()); return result; } - result = closestPoints(geom0->occEdge,geom1->occEdge); + result = closestPoints(geom0->occEdge, geom1->occEdge); return result; } pointPair DrawViewDimension::getPointsTwoVerts() { -// Base::Console().Message("DVD::getPointsTwoVerts() - %s\n",getNameInDocument()); +// Base::Console().Message("DVD::getPointsTwoVerts() - %s\n", getNameInDocument()); pointPair result; const std::vector &subElements = References2D.getSubValues(); @@ -1271,7 +1271,7 @@ pointPair DrawViewDimension::getPointsTwoVerts() TechDraw::VertexPtr v0 = getViewPart()->getProjVertexByIndex(idx0); TechDraw::VertexPtr v1 = getViewPart()->getProjVertexByIndex(idx1); if (!v0 || !v1) { - Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n",getNameInDocument()); + Base::Console().Error("Error: DVD - %s - 2D references are corrupt (3)\n", getNameInDocument()); return result; } result.first = v0->pnt; @@ -1299,7 +1299,7 @@ pointPair DrawViewDimension::getPointsEdgeVert() return result; } - result = closestPoints(e->occEdge,v->occVertex); + result = closestPoints(e->occEdge, v->occVertex); return result; } @@ -1339,16 +1339,16 @@ int DrawViewDimension::getRefTypeSubElements(const std::vector &sub //! validate 2D references - only checks if the target exists bool DrawViewDimension::checkReferences2D() const { -// Base::Console().Message("DVD::checkReFerences2d() - %s\n",getNameInDocument()); +// Base::Console().Message("DVD::checkReFerences2d() - %s\n", getNameInDocument()); const std::vector &objects = References2D.getValues(); if (objects.empty()) { - Base::Console().Log("DVD::checkReferences2d() - %s - objects empty!\n",getNameInDocument()); + Base::Console().Log("DVD::checkReferences2d() - %s - objects empty!\n", getNameInDocument()); return false; } const std::vector &subElements = References2D.getSubValues(); if (subElements.empty()) { - Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n",getNameInDocument()); + Base::Console().Log("DVD::checkRegerences2d() - %s - subelements empty!\n", getNameInDocument()); return false; } @@ -1356,7 +1356,7 @@ bool DrawViewDimension::checkReferences2D() const if (s.empty()) { return false; } - + int idx = DrawUtil::getIndexFromName(s); if (DrawUtil::getGeomTypeFromName(s) == "Edge") { TechDraw::BaseGeomPtr geom = getViewPart()->getGeomByIndex(idx); @@ -1385,9 +1385,9 @@ pointPair DrawViewDimension::closestPoints(TopoDS_Shape s1, int count = extss.NbSolution(); if (count != 0) { gp_Pnt p = extss.PointOnShape1(1); - result.first = Base::Vector3d(p.X(),p.Y(),p.Z()); + result.first = Base::Vector3d(p.X(), p.Y(), p.Z()); p = extss.PointOnShape2(1); - result.second = Base::Vector3d(p.X(),p.Y(),p.Z()); + result.second = Base::Vector3d(p.X(), p.Y(), p.Z()); } //TODO: else { explode } return result; @@ -1415,14 +1415,14 @@ void DrawViewDimension::clear3DMeasurements() void DrawViewDimension::dumpRefs2D(const char* text) const { - Base::Console().Message("DUMP - %s\n",text); + Base::Console().Message("DUMP - %s\n", text); const std::vector &objects = References2D.getValues(); const std::vector &subElements = References2D.getSubValues(); std::vector::const_iterator objIt = objects.begin(); std::vector::const_iterator subIt = subElements.begin(); int i = 0; - for( ;objIt != objects.end();objIt++,subIt++,i++) { - Base::Console().Message("DUMP - ref: %d object: %s subElement: %s\n",i,(*objIt)->getNameInDocument(),(*subIt).c_str()); + for( ;objIt != objects.end();objIt++, subIt++, i++) { + Base::Console().Message("DUMP - ref: %d object: %s subElement: %s\n", i,(*objIt)->getNameInDocument(), (*subIt).c_str()); } } @@ -1431,18 +1431,18 @@ double DrawViewDimension::dist2Segs(Base::Vector3d s1, Base::Vector3d s2, Base::Vector3d e2) const { - gp_Pnt start(s1.x,s1.y,0.0); - gp_Pnt end(e1.x,e1.y,0.0); + gp_Pnt start(s1.x, s1.y, 0.0); + gp_Pnt end(e1.x, e1.y, 0.0); TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(start); TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(end); - BRepBuilderAPI_MakeEdge makeEdge1(v1,v2); + BRepBuilderAPI_MakeEdge makeEdge1(v1, v2); TopoDS_Edge edge1 = makeEdge1.Edge(); - start = gp_Pnt(s2.x,s2.y,0.0); - end = gp_Pnt(e2.x,e2.y,0.0); + start = gp_Pnt(s2.x, s2.y, 0.0); + end = gp_Pnt(e2.x, e2.y, 0.0); v1 = BRepBuilderAPI_MakeVertex(start); v2 = BRepBuilderAPI_MakeVertex(end); - BRepBuilderAPI_MakeEdge makeEdge2(v1,v2); + BRepBuilderAPI_MakeEdge makeEdge2(v1, v2); TopoDS_Edge edge2 = makeEdge2.Edge(); BRepExtrema_DistShapeShape extss(edge1, edge2); @@ -1465,13 +1465,13 @@ bool DrawViewDimension::leaderIntersectsArc(Base::Vector3d s, Base::Vector3d poi TechDraw::BaseGeomPtr base = getViewPart()->getGeomByIndex(idx); if ( base && base->geomType == TechDraw::GeomType::ARCOFCIRCLE ) { TechDraw::AOCPtr aoc = std::static_pointer_cast (base); - if (aoc->intersectsArc(s,pointOnCircle)) { + if (aoc->intersectsArc(s, pointOnCircle)) { result = true; } } else if ( base && base->geomType == TechDraw::GeomType::BSPLINE ) { TechDraw::BSplinePtr spline = std::static_pointer_cast (base); if (spline->isCircle()) { - if (spline->intersectsArc(s,pointOnCircle)) { + if (spline->intersectsArc(s, pointOnCircle)) { result = true; } } @@ -1501,7 +1501,7 @@ pointPair DrawViewDimension::getArrowPositions() bool DrawViewDimension::has2DReferences() const { -// Base::Console().Message("DVD::has2DReferences() - %s\n",getNameInDocument()); +// Base::Console().Message("DVD::has2DReferences() - %s\n", getNameInDocument()); const std::vector &objects = References2D.getValues(); const std::vector &SubNames = References2D.getSubValues(); if (objects.empty() || SubNames.empty()) { @@ -1552,7 +1552,7 @@ std::string DrawViewDimension::getPrefix() const } else if (Type.isValue("Diameter")){ Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); - return std::string(hGrp->GetASCII("DiameterSymbol","\xe2\x8c\x80")); // Diameter symbol + return std::string(hGrp->GetASCII("DiameterSymbol", "\xe2\x8c\x80")); // Diameter symbol } return ""; @@ -1577,14 +1577,14 @@ std::string DrawViewDimension::getDefaultFormatSpec(bool isToleranceFormat) cons std::string prefix = getPrefix(); if (!prefix.empty()) { - qPrefix = QString::fromUtf8(prefix.data(),prefix.size()); + qPrefix = QString::fromUtf8(prefix.data(), prefix.size()); } formatSpec = qPrefix + format1 + formatPrecision + format2; } else { std::string prefix = getPrefix(); - qPrefix = QString::fromUtf8(prefix.data(),prefix.size()); + qPrefix = QString::fromUtf8(prefix.data(), prefix.size()); formatSpec = qPrefix + QString::fromStdString(prefFormat); } @@ -1599,7 +1599,7 @@ std::string DrawViewDimension::getDefaultFormatSpec(bool isToleranceFormat) cons ////! is refName a target of this Dim (2D references) //bool DrawViewDimension::references(std::string refName) const //{ -// Base::Console().Message("DVD::references(%s) - %s\n",refName.c_str(),getNameInDocument()); +// Base::Console().Message("DVD::references(%s) - %s\n", refName.c_str(), getNameInDocument()); // bool result = false; // const std::vector &objects = References2D.getValues(); // if (!objects.empty()) { @@ -1622,7 +1622,7 @@ PyObject *DrawViewDimension::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewDimensionPy(this),true); + PythonObject = Py::Object(new DrawViewDimensionPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawViewDimension.h b/src/Mod/TechDraw/App/DrawViewDimension.h index 9b3b64c6de..2d05f177d4 100644 --- a/src/Mod/TechDraw/App/DrawViewDimension.h +++ b/src/Mod/TechDraw/App/DrawViewDimension.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawViewDimension_h_ -#define _TechDraw_DrawViewDimension_h_ +#ifndef TechDraw_DrawViewDimension_h_ +#define TechDraw_DrawViewDimension_h_ #include @@ -57,9 +57,9 @@ struct anglePoints anglePoints() { - ends.first = Base::Vector3d(0.0,0.0,0.0); - ends.second = Base::Vector3d(0.0,0.0,0.0); - vertex = Base::Vector3d(0.0,0.0,0.0); + ends.first = Base::Vector3d(0.0, 0.0, 0.0); + ends.second = Base::Vector3d(0.0, 0.0, 0.0); + vertex = Base::Vector3d(0.0, 0.0, 0.0); } anglePoints(const anglePoints& ap) @@ -87,16 +87,16 @@ struct arcPoints Base::Vector3d midArc; bool arcCW; - arcPoints() + arcPoints() { isArc = false; radius = 0.0; - center = Base::Vector3d(0.0,0.0,0.0); - onCurve.first = Base::Vector3d(0.0,0.0,0.0); - onCurve.second = Base::Vector3d(0.0,0.0,0.0); - arcEnds.first = Base::Vector3d(0.0,0.0,0.0); - arcEnds.second = Base::Vector3d(0.0,0.0,0.0); - midArc = Base::Vector3d(0.0,0.0,0.0); + center = Base::Vector3d(0.0, 0.0, 0.0); + onCurve.first = Base::Vector3d(0.0, 0.0, 0.0); + onCurve.second = Base::Vector3d(0.0, 0.0, 0.0); + arcEnds.first = Base::Vector3d(0.0, 0.0, 0.0); + arcEnds.second = Base::Vector3d(0.0, 0.0, 0.0); + midArc = Base::Vector3d(0.0, 0.0, 0.0); arcCW = false; } @@ -193,7 +193,7 @@ public: QStringList getPrefixSuffixSpec(QString fSpec); virtual DrawViewPart* getViewPart() const; - QRectF getRect() const override { return QRectF(0,0,1,1);} //pretend dimensions always fit! + QRectF getRect() const override { return {0, 0, 1, 1}; } //pretend dimensions always fit! virtual int getRefType() const; //Vertex-Vertex, Edge, Edge-Edge static int getRefTypeSubElements(const std::vector &); //Vertex-Vertex, Edge, Edge-Edge void setAll3DMeasurement(); diff --git a/src/Mod/TechDraw/App/DrawViewDraft.cpp b/src/Mod/TechDraw/App/DrawViewDraft.cpp index ac4ffe4c91..f5f4838fbe 100644 --- a/src/Mod/TechDraw/App/DrawViewDraft.cpp +++ b/src/Mod/TechDraw/App/DrawViewDraft.cpp @@ -51,22 +51,18 @@ DrawViewDraft::DrawViewDraft() { static const char *group = "Draft view"; - ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"Draft object for this view"); + ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "Draft object for this view"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(LineWidth,(0.35),group,App::Prop_None,"Line width of this view. If Override Style is false, this value multiplies the object line width"); - ADD_PROPERTY_TYPE(FontSize,(12.0),group,App::Prop_None,"Text size for this view"); - ADD_PROPERTY_TYPE(Direction ,(0,0,1.0),group,App::Prop_None,"Projection direction. The direction you are looking from."); - ADD_PROPERTY_TYPE(Color,(0.0f,0.0f,0.0f),group,App::Prop_None,"The default color of text and lines"); - ADD_PROPERTY_TYPE(LineStyle,("Solid") ,group,App::Prop_None,"A line style to use for this view. Can be Solid, Dashed, Dashdot, Dot or a SVG pattern like 0.20,0.20"); - ADD_PROPERTY_TYPE(LineSpacing,(1.0f),group,App::Prop_None,"The spacing between lines to use for multiline texts"); - ADD_PROPERTY_TYPE(OverrideStyle,(false),group,App::Prop_None,"If True, line color, width and style of this view will override those of rendered objects"); + ADD_PROPERTY_TYPE(LineWidth, (0.35), group, App::Prop_None, "Line width of this view. If Override Style is false, this value multiplies the object line width"); + ADD_PROPERTY_TYPE(FontSize, (12.0), group, App::Prop_None, "Text size for this view"); + ADD_PROPERTY_TYPE(Direction ,(0, 0,1.0), group, App::Prop_None, "Projection direction. The direction you are looking from."); + ADD_PROPERTY_TYPE(Color, (0.0f, 0.0f, 0.0f), group, App::Prop_None, "The default color of text and lines"); + ADD_PROPERTY_TYPE(LineStyle, ("Solid") ,group, App::Prop_None, "A line style to use for this view. Can be Solid, Dashed, Dashdot, Dot or a SVG pattern like 0.20, 0.20"); + ADD_PROPERTY_TYPE(LineSpacing, (1.0f), group, App::Prop_None, "The spacing between lines to use for multiline texts"); + ADD_PROPERTY_TYPE(OverrideStyle, (false), group, App::Prop_None, "If True, line color, width and style of this view will override those of rendered objects"); ScaleType.setValue("Custom"); } -DrawViewDraft::~DrawViewDraft() -{ -} - short DrawViewDraft::mustExecute() const { if (!isRestoring()) { @@ -100,34 +96,34 @@ App::DocumentObjectExecReturn *DrawViewDraft::execute() std::string svgTail = getSVGTail(); std::string FeatName = getNameInDocument(); std::string SourceName = sourceObj->getNameInDocument(); - // Draft.get_svg(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False) + // Draft.get_svg(obj, scale=1, linewidth=0.35, fontsize=12, fillstyle="shape color", direction=None, linestyle=None, color=None, linespacing=None, techdraw=False) std::stringstream paramStr; App::Color col = Color.getValue(); - paramStr << ",scale=" << getScale() - << ",linewidth=" << LineWidth.getValue() - << ",fontsize=" << FontSize.getValue() + paramStr << ", scale=" << getScale() + << ", linewidth=" << LineWidth.getValue() + << ", fontsize=" << FontSize.getValue() // TODO treat fillstyle here - << ",direction=FreeCAD.Vector(" << Direction.getValue().x << "," << Direction.getValue().y << "," << Direction.getValue().z << ")" - << ",linestyle=\"" << LineStyle.getValue() << "\"" - << ",color=\"" << col.asHexString() << "\"" - << ",linespacing=" << LineSpacing.getValue() + << ", direction=FreeCAD.Vector(" << Direction.getValue().x << ", " << Direction.getValue().y << ", " << Direction.getValue().z << ")" + << ", linestyle=\"" << LineStyle.getValue() << "\"" + << ", color=\"" << col.asHexString() << "\"" + << ", linespacing=" << LineSpacing.getValue() // We must set techdraw to "true" becausea couple of things behave differently than in Drawing - << ",techdraw=True" - << ",override=" << (OverrideStyle.getValue() ? "True" : "False"); + << ", techdraw=True" + << ", override=" << (OverrideStyle.getValue() ? "True" : "False"); // this is ok for a starting point, but should eventually make dedicated Draft functions that build the svg for all the special cases // (Arch section, etc) // like Draft.makeDrawingView, but we don't need to create the actual document objects in Draft, just the svg. Base::Interpreter().runString("import Draft"); Base::Interpreter().runStringArg("svgBody = Draft.get_svg(App.activeDocument().%s %s)", - SourceName.c_str(),paramStr.str().c_str()); + SourceName.c_str(), paramStr.str().c_str()); // Base::Interpreter().runString("print svgBody"); Base::Interpreter().runStringArg("App.activeDocument().%s.Symbol = '%s' + svgBody + '%s'", - FeatName.c_str(),svgHead.c_str(),svgTail.c_str()); + FeatName.c_str(), svgHead.c_str(), svgTail.c_str()); } - - overrideKeepUpdated(false); + + overrideKeepUpdated(false); return DrawView::execute(); } diff --git a/src/Mod/TechDraw/App/DrawViewDraft.h b/src/Mod/TechDraw/App/DrawViewDraft.h index 3993042853..06d9620873 100644 --- a/src/Mod/TechDraw/App/DrawViewDraft.h +++ b/src/Mod/TechDraw/App/DrawViewDraft.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewDraft_h_ -#define _DrawViewDraft_h_ +#ifndef DrawViewDraft_h_ +#define DrawViewDraft_h_ #include @@ -43,7 +43,7 @@ class TechDrawExport DrawViewDraft : public TechDraw::DrawViewSymbol public: /// Constructor DrawViewDraft(); - ~DrawViewDraft() override; + ~DrawViewDraft() = default; App::PropertyLink Source; App::PropertyFloat LineWidth; diff --git a/src/Mod/TechDraw/App/DrawViewImage.cpp b/src/Mod/TechDraw/App/DrawViewImage.cpp index b62cac2501..1d3ff8457a 100644 --- a/src/Mod/TechDraw/App/DrawViewImage.cpp +++ b/src/Mod/TechDraw/App/DrawViewImage.cpp @@ -54,21 +54,17 @@ DrawViewImage::DrawViewImage() { static const char *vgroup = "Image"; - ADD_PROPERTY_TYPE(ImageFile,(""),vgroup,App::Prop_None,"The file containing this bitmap"); - ADD_PROPERTY_TYPE(ImageIncluded, (""), vgroup,App::Prop_None, + ADD_PROPERTY_TYPE(ImageFile, (""), vgroup, App::Prop_None, "The file containing this bitmap"); + ADD_PROPERTY_TYPE(ImageIncluded, (""), vgroup, App::Prop_None, "Embedded image file. System use only."); // n/a to end users - ADD_PROPERTY_TYPE(Width ,(100),vgroup,App::Prop_None,"The width of cropped image"); - ADD_PROPERTY_TYPE(Height ,(100),vgroup,App::Prop_None,"The height of cropped image"); + ADD_PROPERTY_TYPE(Width ,(100), vgroup, App::Prop_None, "The width of cropped image"); + ADD_PROPERTY_TYPE(Height ,(100), vgroup, App::Prop_None, "The height of cropped image"); ScaleType.setValue("Custom"); std::string imgFilter("Image files (*.jpg *.jpeg *.png);;All files (*)"); ImageFile.setFilter(imgFilter); } -DrawViewImage::~DrawViewImage() -{ -} - void DrawViewImage::onChanged(const App::Property* prop) { App::Document* doc = getDocument(); @@ -106,7 +102,7 @@ App::DocumentObjectExecReturn *DrawViewImage::execute() QRectF DrawViewImage::getRect() const { - return QRectF(0.0,0.0,Width.getValue(), Height.getValue()); + return { 0.0, 0.0, Width.getValue(), Height.getValue()}; } void DrawViewImage::replaceImageIncluded(std::string newFileName) diff --git a/src/Mod/TechDraw/App/DrawViewImage.h b/src/Mod/TechDraw/App/DrawViewImage.h index 69a5a1f61f..ec1af6bd87 100644 --- a/src/Mod/TechDraw/App/DrawViewImage.h +++ b/src/Mod/TechDraw/App/DrawViewImage.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewImage_h_ -#define _DrawViewImage_h_ +#ifndef DrawViewImage_h_ +#define DrawViewImage_h_ #include @@ -43,7 +43,7 @@ class TechDrawExport DrawViewImage : public TechDraw::DrawView public: /// Constructor DrawViewImage(); - ~DrawViewImage() override; + ~DrawViewImage() = default; App::PropertyFile ImageFile; App::PropertyFileIncluded ImageIncluded; diff --git a/src/Mod/TechDraw/App/DrawViewMulti.cpp b/src/Mod/TechDraw/App/DrawViewMulti.cpp index 21b4624c76..e567eb3c21 100644 --- a/src/Mod/TechDraw/App/DrawViewMulti.cpp +++ b/src/Mod/TechDraw/App/DrawViewMulti.cpp @@ -79,11 +79,11 @@ DrawViewMulti::DrawViewMulti() static const char *group = "Projection"; //properties that affect Geometry - ADD_PROPERTY_TYPE(Sources ,(nullptr),group,App::Prop_None,"3D Shapes to view"); + ADD_PROPERTY_TYPE(Sources ,(nullptr), group, App::Prop_None, "3D Shapes to view"); Sources.setScope(App::LinkScope::Global); //Source is replaced by Sources in Multi - Source.setStatus(App::Property::ReadOnly,true); - Source.setStatus(App::Property::Hidden,true); + Source.setStatus(App::Property::ReadOnly, true); + Source.setStatus(App::Property::Hidden, true); geometryObject = nullptr; } @@ -104,7 +104,7 @@ short DrawViewMulti::mustExecute() const void DrawViewMulti::onChanged(const App::Property* prop) { if (!isRestoring()) { - //Base::Console().Message("TRACE - DVM::onChanged(%s) - %s\n",prop->getName(),Label.getValue()); + //Base::Console().Message("TRACE - DVM::onChanged(%s) - %s\n", prop->getName(), Label.getValue()); if (prop == &Sources) { const std::vector& links = Sources.getValues(); if (!links.empty()) { @@ -138,24 +138,24 @@ App::DocumentObjectExecReturn *DrawViewMulti::execute() try { inputCenter = TechDraw::findCentroid(comp, Direction.getValue()); - shapeCentroid = Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()); + shapeCentroid = Base::Vector3d(inputCenter.X(), inputCenter.Y(), inputCenter.Z()); TopoDS_Shape mirroredShape = TechDraw::mirrorShape(comp, inputCenter, getScale()); - gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(),inputCenter.Y(),inputCenter.Z()),Direction.getValue()); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + gp_Ax2 viewAxis = getViewAxis(Base::Vector3d(inputCenter.X(), inputCenter.Y(), inputCenter.Z()), Direction.getValue()); + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { mirroredShape = TechDraw::rotateShape(mirroredShape, viewAxis, Rotation.getValue()); } - geometryObject = buildGeometryObject(mirroredShape,viewAxis); + geometryObject = buildGeometryObject(mirroredShape, viewAxis); #if MOD_TECHDRAW_HANDLE_FACES extractFaces(); #endif //#if MOD_TECHDRAW_HANDLE_FACES } catch (Standard_Failure& e1) { - Base::Console().Log("LOG - DVM::execute - projection failed for %s - %s **\n",getNameInDocument(),e1.GetMessageString()); + Base::Console().Log("LOG - DVM::execute - projection failed for %s - %s **\n", getNameInDocument(), e1.GetMessageString()); return new App::DocumentObjectExecReturn(e1.GetMessageString()); } diff --git a/src/Mod/TechDraw/App/DrawViewMulti.h b/src/Mod/TechDraw/App/DrawViewMulti.h index bd2004369c..c8f959f7f7 100644 --- a/src/Mod/TechDraw/App/DrawViewMulti.h +++ b/src/Mod/TechDraw/App/DrawViewMulti.h @@ -22,8 +22,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewMulti_h_ -#define _DrawViewMulti_h_ +#ifndef DrawViewMulti_h_ +#define DrawViewMulti_h_ #include @@ -58,7 +58,7 @@ public: /// Constructor DrawViewMulti(); ~DrawViewMulti() override; - + App::PropertyLinkList Sources; short mustExecute() const override; diff --git a/src/Mod/TechDraw/App/DrawViewPart.cpp b/src/Mod/TechDraw/App/DrawViewPart.cpp index d4ed6f1365..167a87a987 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.cpp +++ b/src/Mod/TechDraw/App/DrawViewPart.cpp @@ -99,7 +99,7 @@ using namespace std; //PROPERTY_SOURCE(TechDraw::DrawViewPart, TechDraw::DrawView) -PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart, +PROPERTY_SOURCE_WITH_EXTENSIONS(TechDraw::DrawViewPart, TechDraw::DrawView) DrawViewPart::DrawViewPart(void) : @@ -118,34 +118,34 @@ DrawViewPart::DrawViewPart(void) : Base::Reference hGrp = App::GetApplication(). GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - double defDist = hGrp->GetFloat("FocusDistance",100.0); + double defDist = hGrp->GetFloat("FocusDistance", 100.0); //properties that affect Geometry - ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"3D Shape to view"); + ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "3D Shape to view"); Source.setScope(App::LinkScope::Global); Source.setAllowExternal(true); - ADD_PROPERTY_TYPE(XSource ,(nullptr),group,App::Prop_None,"External 3D Shape to view"); + ADD_PROPERTY_TYPE(XSource ,(nullptr), group, App::Prop_None, "External 3D Shape to view"); - ADD_PROPERTY_TYPE(Direction ,(0.0,-1.0,0.0), - group,App::Prop_None,"Projection Plane normal. The direction you are looking from."); - ADD_PROPERTY_TYPE(XDirection ,(0.0,0.0,0.0), - group,App::Prop_None,"Projection Plane X Axis in R3. Rotates/Mirrors View"); - ADD_PROPERTY_TYPE(Perspective ,(false),group,App::Prop_None, + ADD_PROPERTY_TYPE(Direction ,(0.0, -1.0, 0.0), + group, App::Prop_None, "Projection Plane normal. The direction you are looking from."); + ADD_PROPERTY_TYPE(XDirection ,(0.0, 0.0, 0.0), + group, App::Prop_None, "Projection Plane X Axis in R3. Rotates/Mirrors View"); + ADD_PROPERTY_TYPE(Perspective ,(false), group, App::Prop_None, "Perspective(true) or Orthographic(false) projection"); - ADD_PROPERTY_TYPE(Focus,(defDist),group,App::Prop_None,"Perspective view focus distance"); + ADD_PROPERTY_TYPE(Focus, (defDist), group, App::Prop_None, "Perspective view focus distance"); //properties that control HLR algo bool coarseView = hGrp->GetBool("CoarseView", false); ADD_PROPERTY_TYPE(CoarseView, (coarseView), sgroup, App::Prop_None, "Coarse View on/off"); - ADD_PROPERTY_TYPE(SmoothVisible ,(prefSmoothViz()),sgroup,App::Prop_None,"Show Visible Smooth lines"); - ADD_PROPERTY_TYPE(SeamVisible ,(prefSeamViz()),sgroup,App::Prop_None,"Show Visible Seam lines"); - ADD_PROPERTY_TYPE(IsoVisible ,(prefIsoViz()),sgroup,App::Prop_None,"Show Visible Iso u,v lines"); - ADD_PROPERTY_TYPE(HardHidden ,(prefHardHid()),sgroup,App::Prop_None,"Show Hidden Hard lines"); - ADD_PROPERTY_TYPE(SmoothHidden ,(prefSmoothHid()),sgroup,App::Prop_None,"Show Hidden Smooth lines"); - ADD_PROPERTY_TYPE(SeamHidden ,(prefSeamHid()),sgroup,App::Prop_None,"Show Hidden Seam lines"); - ADD_PROPERTY_TYPE(IsoHidden ,(prefIsoHid()),sgroup,App::Prop_None,"Show Hidden Iso u,v lines"); - ADD_PROPERTY_TYPE(IsoCount ,(prefIsoCount()),sgroup,App::Prop_None,"Number of iso parameters lines"); + ADD_PROPERTY_TYPE(SmoothVisible ,(prefSmoothViz()), sgroup, App::Prop_None, "Show Visible Smooth lines"); + ADD_PROPERTY_TYPE(SeamVisible ,(prefSeamViz()), sgroup, App::Prop_None, "Show Visible Seam lines"); + ADD_PROPERTY_TYPE(IsoVisible ,(prefIsoViz()), sgroup, App::Prop_None, "Show Visible Iso u, v lines"); + ADD_PROPERTY_TYPE(HardHidden ,(prefHardHid()), sgroup, App::Prop_None, "Show Hidden Hard lines"); + ADD_PROPERTY_TYPE(SmoothHidden ,(prefSmoothHid()), sgroup, App::Prop_None, "Show Hidden Smooth lines"); + ADD_PROPERTY_TYPE(SeamHidden ,(prefSeamHid()), sgroup, App::Prop_None, "Show Hidden Seam lines"); + ADD_PROPERTY_TYPE(IsoHidden ,(prefIsoHid()), sgroup, App::Prop_None, "Show Hidden Iso u, v lines"); + ADD_PROPERTY_TYPE(IsoCount ,(prefIsoCount()), sgroup, App::Prop_None, "Number of iso parameters lines"); //initialize bbox to non-garbage bbox = Base::BoundBox3d(Base::Vector3d(0.0, 0.0, 0.0), 0.0); @@ -243,7 +243,6 @@ void DrawViewPart::addShapes2d(void) App::DocumentObjectExecReturn *DrawViewPart::execute(void) { // Base::Console().Message("DVP::execute() - %s\n", getNameInDocument()); - if (!keepUpdated()) { return DrawView::execute(); } @@ -251,7 +250,7 @@ App::DocumentObjectExecReturn *DrawViewPart::execute(void) if (waitingForHlr()) { return DrawView::execute(); } - + TopoDS_Shape shape = getSourceShape(); if (shape.IsNull()) { Base::Console().Log("DVP::execute - %s - Source shape is Null.\n", @@ -335,7 +334,7 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape) { // Base::Console().Message("DVP::makeGeometryForShape() - %s\n", getNameInDocument()); gp_Pnt inputCenter; - Base::Vector3d stdOrg(0.0,0.0,0.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); gp_Ax2 viewAxis = getProjectionCS(stdOrg); inputCenter = TechDraw::findCentroid(shape, viewAxis); @@ -351,13 +350,13 @@ GeometryObject* DrawViewPart::makeGeometryForShape(TopoDS_Shape& shape) TopoDS_Shape scaledShape = TechDraw::scaleShape(centeredShape, getScale()); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { scaledShape = TechDraw::rotateShape(scaledShape, viewAxis, Rotation.getValue()); //conventional rotation } // BRepTools::Write(scaledShape, "DVPScaled.brep"); //debug - GeometryObject* go = buildGeometryObject(scaledShape,viewAxis); + GeometryObject* go = buildGeometryObject(scaledShape, viewAxis); return go; } @@ -429,7 +428,7 @@ void DrawViewPart::onHlrFinished(void) } catch (Standard_Failure& e) { waitingForFaces(false); - Base::Console().Error("DVP::partExec - %s - extractFaces failed - %s **\n",getNameInDocument(), e.GetMessageString()); + Base::Console().Error("DVP::partExec - %s - extractFaces failed - %s **\n", getNameInDocument(), e.GetMessageString()); throw Base::RuntimeError("DVP::onHlrFinished - error extracting faces"); } } @@ -485,7 +484,7 @@ void DrawViewPart::extractFaces() //make a copy of the input edges so the loose tolerances of face finding are //not applied to the real edge geometry. See TopoDS_Shape::TShape(). const std::vector& goEdges = - geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue()); + geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(), SeamVisible.getValue()); if (goEdges.empty()) { Base::Console().Message("DVP::extractFaces - %s - no face edges available!\n", getNameInDocument()); @@ -525,7 +524,7 @@ void DrawViewPart::extractFaces() } int iInner = 0; std::vector::iterator itInner = nonZero.begin(); //***sb itOuter + 1; - for (; itInner != nonZero.end(); ++itInner,iInner++) { + for (; itInner != nonZero.end(); ++itInner, iInner++) { if (iInner == iOuter) { continue; } @@ -544,19 +543,19 @@ void DrawViewPart::extractFaces() } double param = -1; //parametric point on edge where the vertex touches - if (DrawProjectSplit::isOnEdge((*itInner),v1,param,false)) { + if (DrawProjectSplit::isOnEdge((*itInner), v1, param, false)) { gp_Pnt pnt1 = BRep_Tool::Pnt(v1); splitPoint s1; s1.i = iInner; - s1.v = Base::Vector3d(pnt1.X(),pnt1.Y(),pnt1.Z()); + s1.v = Base::Vector3d(pnt1.X(), pnt1.Y(), pnt1.Z()); s1.param = param; splits.push_back(s1); } - if (DrawProjectSplit::isOnEdge((*itInner),v2,param,false)) { + if (DrawProjectSplit::isOnEdge((*itInner), v2, param, false)) { gp_Pnt pnt2 = BRep_Tool::Pnt(v2); splitPoint s2; s2.i = iInner; - s2.v = Base::Vector3d(pnt2.X(),pnt2.Y(),pnt2.Z()); + s2.v = Base::Vector3d(pnt2.X(), pnt2.Y(), pnt2.Z()); s2.param = param; splits.push_back(s2); } @@ -564,11 +563,11 @@ void DrawViewPart::extractFaces() } //outer loop //if edge A was touched at the same point by multiple edges B, we only want to split A once - std::vector sorted = DrawProjectSplit::sortSplits(splits,true); + std::vector sorted = DrawProjectSplit::sortSplits(splits, true); auto last = std::unique(sorted.begin(), sorted.end(), DrawProjectSplit::splitEqual); //duplicates to back sorted.erase(last, sorted.end()); //remove duplicate splits - std::vector newEdges = DrawProjectSplit::splitEdges(nonZero,sorted); + std::vector newEdges = DrawProjectSplit::splitEdges(nonZero, sorted); if (newEdges.empty()) { Base::Console().Log("DVP::extractFaces - no edges return by splitting process\n"); @@ -590,7 +589,7 @@ void DrawViewPart::extractFaces() } std::vector fw = ew.getResultNoDups(); - std::vector sortedWires = ew.sortStrip(fw,true); + std::vector sortedWires = ew.sortStrip(fw, true); std::vector::iterator itWire = sortedWires.begin(); for (; itWire != sortedWires.end(); itWire++) { @@ -657,8 +656,8 @@ std::vector DrawViewPart::getDimensions() const { std::vector result; std::vector children = getInList(); - std::sort(children.begin(),children.end(),std::less()); - std::vector::iterator newEnd = std::unique(children.begin(),children.end()); + std::sort(children.begin(), children.end(), std::less()); + std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) { if ((*it)->getTypeId().isDerivedFrom(DrawViewDimension::getClassTypeId())) { TechDraw::DrawViewDimension* dim = dynamic_cast(*it); @@ -672,8 +671,8 @@ std::vector DrawViewPart::getBalloons() const { std::vector result; std::vector children = getInList(); - std::sort(children.begin(),children.end(),std::less()); - std::vector::iterator newEnd = std::unique(children.begin(),children.end()); + std::sort(children.begin(), children.end(), std::less()); + std::vector::iterator newEnd = std::unique(children.begin(), children.end()); for (std::vector::iterator it = children.begin(); it != newEnd; ++it) { if ((*it)->getTypeId().isDerivedFrom(DrawViewBalloon::getClassTypeId())) { TechDraw::DrawViewBalloon* balloon = dynamic_cast(*it); @@ -715,7 +714,7 @@ TechDraw::BaseGeomPtr DrawViewPart::getGeomByIndex(int idx) const { const std::vector &geoms = getEdgeGeometry(); if (geoms.empty()) { - Base::Console().Log("DVP::getGeomByIndex(%d) - no Edge Geometry. Probably restoring?\n",idx); + Base::Console().Log("DVP::getGeomByIndex(%d) - no Edge Geometry. Probably restoring?\n", idx); return nullptr; } if ((unsigned)idx >= geoms.size()) { @@ -730,11 +729,11 @@ TechDraw::VertexPtr DrawViewPart::getProjVertexByIndex(int idx) const { const std::vector &geoms = getVertexGeometry(); if (geoms.empty()) { - Base::Console().Log("DVP::getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n",idx); + Base::Console().Log("DVP::getProjVertexByIndex(%d) - no Vertex Geometry. Probably restoring?\n", idx); return nullptr; } if ((unsigned)idx >= geoms.size()) { - Base::Console().Error("DVP::getProjVertexByIndex(%d) - invalid index\n",idx); + Base::Console().Error("DVP::getProjVertexByIndex(%d) - invalid index\n", idx); return nullptr; } return geoms.at(idx); @@ -748,7 +747,7 @@ TechDraw::VertexPtr DrawViewPart::getProjVertexByCosTag(std::string cosTag) Base::Console().Log("INFO - getProjVertexByCosTag(%s) - no Vertex Geometry.\n"); return result; } - + for (auto& gv: gVerts) { if (gv->cosmeticTag == cosTag) { result = gv; @@ -830,14 +829,14 @@ QRectF DrawViewPart::getRect() const Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt, bool invert) const { // Base::Console().Message("DVP::projectPoint()\n"); - Base::Vector3d stdOrg(0.0,0.0,0.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); gp_Ax2 viewAxis = getProjectionCS(stdOrg); - gp_Pnt gPt(pt.x,pt.y,pt.z); + gp_Pnt gPt(pt.x, pt.y, pt.z); HLRAlgo_Projector projector( viewAxis ); gp_Pnt2d prjPnt; projector.Project(gPt, prjPnt); - Base::Vector3d result(prjPnt.X(),prjPnt.Y(), 0.0); + Base::Vector3d result(prjPnt.X(), prjPnt.Y(), 0.0); if (invert) { result = DrawUtil::invertY(result); } @@ -848,7 +847,7 @@ Base::Vector3d DrawViewPart::projectPoint(const Base::Vector3d& pt, bool invert) //TODO:: loose edges not supported yet BaseGeomPtr DrawViewPart::projectEdge(const TopoDS_Edge& e) const { - Base::Vector3d stdOrg(0.0,0.0,0.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); gp_Ax2 viewAxis = getProjectionCS(stdOrg); gp_Pln plane(viewAxis); @@ -971,7 +970,7 @@ std::vector DrawViewPart::getDetailRefs() const const BaseGeomPtrVector DrawViewPart::getVisibleFaceEdges() const { - return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(),SeamVisible.getValue()); + return geometryObject->getVisibleFaceEdges(SmoothVisible.getValue(), SeamVisible.getValue()); } bool DrawViewPart::handleFaces() @@ -982,7 +981,7 @@ bool DrawViewPart::handleFaces() } //! remove features that are useless without this DVP -//! hatches, geomhatches, dimensions,... +//! hatches, geomhatches, dimensions, ... void DrawViewPart::unsetupObject() { nowUnsetting = true; @@ -1045,8 +1044,8 @@ bool DrawViewPart::isIso() const { bool result = false; Base::Vector3d dir = Direction.getValue(); - if ( DrawUtil::fpCompare(fabs(dir.x),fabs(dir.y)) && - DrawUtil::fpCompare(fabs(dir.x),fabs(dir.z)) ) { + if ( DrawUtil::fpCompare(fabs(dir.x), fabs(dir.y)) && + DrawUtil::fpCompare(fabs(dir.x), fabs(dir.z)) ) { result = true; } return result; @@ -1058,7 +1057,7 @@ bool DrawViewPart::checkXDirection() const Base::Vector3d xDir = XDirection.getValue(); if (DrawUtil::fpCompare(xDir.Length(), 0.0)) { Base::Vector3d dir = Direction.getValue(); - Base::Vector3d origin(0.0,0.0,0.0); + Base::Vector3d origin(0.0, 0.0, 0.0); Base::Vector3d xDir = getLegacyX(origin, dir); Base::Console().Log("DVP - %s - XDirection property not set. Trying %s\n", @@ -1130,7 +1129,7 @@ void DrawViewPart::addReferencesToGeom() //ex. LandmarkDimension as a reference std::string DrawViewPart::addReferenceVertex(Base::Vector3d v) { -// Base::Console().Message("DVP::addReferenceVertex(%s) - %s\n", +// Base::Console().Message("DVP::addReferenceVertex(%s) - %s\n", // DrawUtil::formatVector(v).c_str(), getNameInDocument()); std::string refTag; // Base::Vector3d scaledV = v * getScale(); @@ -1154,7 +1153,7 @@ void DrawViewPart::removeReferenceVertex(std::string tag) } } m_referenceVerts = newRefVerts; - resetReferenceVerts(); + resetReferenceVerts(); } void DrawViewPart::removeAllReferencesFromGeom() @@ -1215,7 +1214,7 @@ int DrawViewPart::add1CVToGV(std::string tag) return iGV; } -//update Vertex geometry with current CV's +//update Vertex geometry with current CV's void DrawViewPart::refreshCVGeoms() { // Base::Console().Message("DVP::refreshCVGeoms()\n"); @@ -1253,7 +1252,7 @@ int DrawViewPart::getCVIndex(std::string tag) int base = gVerts.size(); int i = 0; for (auto& cv: cVerts) { -// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n", +// Base::Console().Message("DVP::getCVIndex - cv tag: %s\n", // cv->getTagAsString().c_str()); if (cv->getTagAsString() == tag) { result = base + i; @@ -1285,7 +1284,7 @@ void DrawViewPart::addCosmeticEdgesToGeom() TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale()); if (!scaledGeom) continue; -// int iGE = +// int iGE = geometryObject->addCosmeticEdge(scaledGeom, ce->getTagAsString()); } @@ -1302,11 +1301,11 @@ int DrawViewPart::add1CEToGE(std::string tag) TechDraw::BaseGeomPtr scaledGeom = ce->scaledGeometry(getScale()); int iGE = geometryObject->addCosmeticEdge(scaledGeom, tag); - + return iGE; } -//update Edge geometry with current CE's +//update Edge geometry with current CE's void DrawViewPart::refreshCEGeoms() { // Base::Console().Message("DVP::refreshCEGeoms()\n"); @@ -1340,11 +1339,11 @@ int DrawViewPart::add1CLToGE(std::string tag) TechDraw::BaseGeomPtr scaledGeom = cl->scaledGeometry(this); int iGE = geometryObject->addCenterLine(scaledGeom, tag); - + return iGE; } -//update Edge geometry with current CL's +//update Edge geometry with current CL's void DrawViewPart::refreshCLGeoms() { // Base::Console().Message("DVP::refreshCLGeoms()\n"); @@ -1423,21 +1422,11 @@ void DrawViewPart::dumpCosEdges(std::string text) } } - - -void DrawViewPart::onDocumentRestored() -{ -// requestPaint(); - //if execute has not run yet, there will be no GO, and paint will not do anything. - recomputeFeature(); - DrawView::onDocumentRestored(); -} - PyObject *DrawViewPart::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewPartPy(this),true); + PythonObject = Py::Object(new DrawViewPartPy(this), true); } return Py::new_reference_to(PythonObject); } @@ -1452,7 +1441,7 @@ bool DrawViewPart::prefHardViz() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("HardViz", true); + bool result = hGrp->GetBool("HardViz", true); return result; } @@ -1460,7 +1449,7 @@ bool DrawViewPart::prefSeamViz() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("SeamViz", true); + bool result = hGrp->GetBool("SeamViz", true); return result; } @@ -1468,7 +1457,7 @@ bool DrawViewPart::prefSmoothViz() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("SmoothViz", true); + bool result = hGrp->GetBool("SmoothViz", true); return result; } @@ -1476,7 +1465,7 @@ bool DrawViewPart::prefIsoViz() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("IsoViz", false); + bool result = hGrp->GetBool("IsoViz", false); return result; } @@ -1484,7 +1473,7 @@ bool DrawViewPart::prefHardHid() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("HardHid", false); + bool result = hGrp->GetBool("HardHid", false); return result; } @@ -1492,7 +1481,7 @@ bool DrawViewPart::prefSeamHid() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("SeamHid", false); + bool result = hGrp->GetBool("SeamHid", false); return result; } @@ -1500,7 +1489,7 @@ bool DrawViewPart::prefSmoothHid() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("SmoothHid", false); + bool result = hGrp->GetBool("SmoothHid", false); return result; } @@ -1508,7 +1497,7 @@ bool DrawViewPart::prefIsoHid() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - bool result = hGrp->GetBool("IsoHid", false); + bool result = hGrp->GetBool("IsoHid", false); return result; } @@ -1516,7 +1505,7 @@ int DrawViewPart::prefIsoCount() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/HLR"); - int result = hGrp->GetBool("IsoCount", 0); + int result = hGrp->GetBool("IsoCount", 0); return result; } diff --git a/src/Mod/TechDraw/App/DrawViewPart.h b/src/Mod/TechDraw/App/DrawViewPart.h index 76114b8127..796c4a7034 100644 --- a/src/Mod/TechDraw/App/DrawViewPart.h +++ b/src/Mod/TechDraw/App/DrawViewPart.h @@ -22,8 +22,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewPart_h_ -#define _DrawViewPart_h_ +#ifndef DrawViewPart_h_ +#define DrawViewPart_h_ #include @@ -110,7 +110,6 @@ public: App::PropertyInteger IsoCount; short mustExecute() const override; - void onDocumentRestored() override; App::DocumentObjectExecReturn *execute() override; const char* getViewProviderName() const override { return "TechDrawGui::ViewProviderViewPart"; @@ -162,7 +161,7 @@ public: bool handleFaces(); bool isUnsetting() { return nowUnsetting; } - + virtual std::vector getWireForFace(int idx) const; virtual TopoDS_Shape getSourceShape() const; @@ -273,4 +272,4 @@ using DrawViewPartPython = App::FeaturePythonT; } //namespace TechDraw -#endif // #ifndef _DrawViewPart_h_ +#endif // #ifndef DrawViewPart_h_ diff --git a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp index ca00161fbb..17ffc5f652 100644 --- a/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewPartPyImp.cpp @@ -291,7 +291,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args) &(Base::VectorPy::Type), &pPnt2, &style, &weight, &pColor)) { - throw Py::TypeError("expected (vector, vector,[style,weight,color])"); + throw Py::TypeError("expected (vector, vector, [style, weight, color])"); } DrawViewPart* dvp = getDrawViewPartPtr(); @@ -308,7 +308,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine(PyObject *args) ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor); } else { std::string msg = "DVPPI:makeCosmeticLine - line creation failed"; - Base::Console().Message("%s\n",msg.c_str()); + Base::Console().Message("%s\n", msg.c_str()); throw Py::RuntimeError(msg); } //int link = @@ -330,7 +330,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args) &(Base::VectorPy::Type), &pPnt2, &style, &weight, &pColor)) { - throw Py::TypeError("expected (vector, vector,[style,weight,color])"); + throw Py::TypeError("expected (vector, vector, [style, weight, color])"); } DrawViewPart* dvp = getDrawViewPartPtr(); @@ -355,7 +355,7 @@ PyObject* DrawViewPartPy::makeCosmeticLine3D(PyObject *args) ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor); } else { std::string msg = "DVPPI:makeCosmeticLine - line creation failed"; - Base::Console().Message("%s\n",msg.c_str()); + Base::Console().Message("%s\n", msg.c_str()); throw Py::RuntimeError(msg); } //int link = @@ -376,7 +376,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args) &radius, &style, &weight, &pColor)) { - throw Py::TypeError("expected (vector, vector,[style,weight,color])"); + throw Py::TypeError("expected (vector, vector, [style, weight, color])"); } DrawViewPart* dvp = getDrawViewPartPtr(); @@ -394,7 +394,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircle(PyObject *args) ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor); } else { std::string msg = "DVPPI:makeCosmeticCircle - circle creation failed"; - Base::Console().Message("%s\n",msg.c_str()); + Base::Console().Message("%s\n", msg.c_str()); throw Py::RuntimeError(msg); } //int link = @@ -417,7 +417,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args) if (!PyArg_ParseTuple(args, "O!ddd|idO", &(Base::VectorPy::Type), &pPnt1, &radius, &angle1, &angle2, &style, &weight, &pColor)) { - throw Py::TypeError("expected (vector, radius, start, end,[style, weight, color])"); + throw Py::TypeError("expected (vector, radius, start, end, [style, weight, color])"); } //from here on is almost duplicate of makeCosmeticCircle @@ -436,7 +436,7 @@ PyObject* DrawViewPartPy::makeCosmeticCircleArc(PyObject *args) ce->m_format.m_color = DrawUtil::pyTupleToColor(pColor); } else { std::string msg = "DVPPI:makeCosmeticCircleArc - arc creation failed"; - Base::Console().Message("%s\n",msg.c_str()); + Base::Console().Message("%s\n", msg.c_str()); throw Py::RuntimeError(msg); } @@ -507,7 +507,7 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args) int mode = 0; std::vector subs; - if (!PyArg_ParseTuple(args, "Oi",&pSubs, &mode)) { + if (!PyArg_ParseTuple(args, "Oi", &pSubs, &mode)) { throw Py::TypeError("expected (subNameList, mode)"); } @@ -528,12 +528,12 @@ PyObject* DrawViewPartPy::makeCenterLine(PyObject *args) if (!subs.empty()) { cl = CenterLine::CenterLineBuilder(dvp, subs, - mode); //vert,horiz,align + mode); //vert, horiz, align if (cl) { tag = dvp->addCenterLine(cl); } else { std::string msg = "DVPPI:makeCenterLine - line creation failed"; - Base::Console().Message("%s\n",msg.c_str()); + Base::Console().Message("%s\n", msg.c_str()); throw Py::RuntimeError(msg); } } @@ -606,7 +606,7 @@ PyObject* DrawViewPartPy::formatGeometricEdge(PyObject *args) int visible = 1; PyObject* pColor; - if (!PyArg_ParseTuple(args, "iidOi",&idx, &style, &weight, &pColor, &visible)) { + if (!PyArg_ParseTuple(args, "iidOi", &idx, &style, &weight, &pColor, &visible)) { throw Py::TypeError("expected (index, style, weight, color, visible)"); } diff --git a/src/Mod/TechDraw/App/DrawViewSection.cpp b/src/Mod/TechDraw/App/DrawViewSection.cpp index b2b0ae64d0..690ed1678c 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.cpp +++ b/src/Mod/TechDraw/App/DrawViewSection.cpp @@ -108,29 +108,29 @@ DrawViewSection::DrawViewSection() : static const char *sgroup = "Section"; static const char *fgroup = "Cut Surface Format"; - ADD_PROPERTY_TYPE(SectionSymbol ,(""),sgroup,App::Prop_None,"The identifier for this section"); - ADD_PROPERTY_TYPE(BaseView ,(nullptr),sgroup,App::Prop_None,"2D View source for this Section"); + ADD_PROPERTY_TYPE(SectionSymbol ,(""), sgroup, App::Prop_None, "The identifier for this section"); + ADD_PROPERTY_TYPE(BaseView ,(nullptr), sgroup, App::Prop_None, "2D View source for this Section"); BaseView.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(SectionNormal ,(0,0,1.0) ,sgroup,App::Prop_None, + ADD_PROPERTY_TYPE(SectionNormal ,(0, 0,1.0) ,sgroup, App::Prop_None, "Section Plane normal direction"); //direction of extrusion of cutting prism - ADD_PROPERTY_TYPE(SectionOrigin ,(0,0,0) ,sgroup,App::Prop_None,"Section Plane Origin"); + ADD_PROPERTY_TYPE(SectionOrigin ,(0, 0,0) ,sgroup, App::Prop_None, "Section Plane Origin"); SectionDirection.setEnums(SectionDirEnums); - ADD_PROPERTY_TYPE(SectionDirection,((long)0),sgroup, App::Prop_None, "Direction in Base View for this Section"); - ADD_PROPERTY_TYPE(FuseBeforeCut ,(false),sgroup,App::Prop_None,"Merge Source(s) into a single shape before cutting"); + ADD_PROPERTY_TYPE(SectionDirection, ((long)0), sgroup, App::Prop_None, "Direction in Base View for this Section"); + ADD_PROPERTY_TYPE(FuseBeforeCut ,(false), sgroup, App::Prop_None, "Merge Source(s) into a single shape before cutting"); CutSurfaceDisplay.setEnums(CutSurfaceEnums); - ADD_PROPERTY_TYPE(CutSurfaceDisplay,(prefCutSurface()),fgroup, App::Prop_None, "Appearance of Cut Surface"); + ADD_PROPERTY_TYPE(CutSurfaceDisplay, (prefCutSurface()), fgroup, App::Prop_None, "Appearance of Cut Surface"); //initialize these to defaults - ADD_PROPERTY_TYPE(FileHatchPattern ,(DrawHatch::prefSvgHatch()),fgroup,App::Prop_None,"The hatch pattern file for the cut surface"); - ADD_PROPERTY_TYPE(FileGeomPattern ,(DrawGeomHatch::prefGeomHatchFile()),fgroup,App::Prop_None,"The PAT pattern file for geometric hatching"); + ADD_PROPERTY_TYPE(FileHatchPattern ,(DrawHatch::prefSvgHatch()), fgroup, App::Prop_None, "The hatch pattern file for the cut surface"); + ADD_PROPERTY_TYPE(FileGeomPattern ,(DrawGeomHatch::prefGeomHatchFile()), fgroup, App::Prop_None, "The PAT pattern file for geometric hatching"); - ADD_PROPERTY_TYPE(SvgIncluded ,(""),fgroup,App::Prop_None, + ADD_PROPERTY_TYPE(SvgIncluded ,(""), fgroup, App::Prop_None, "Embedded Svg hatch file. System use only."); // n/a to end users - ADD_PROPERTY_TYPE(PatIncluded ,(""),fgroup,App::Prop_None, + ADD_PROPERTY_TYPE(PatIncluded ,(""), fgroup, App::Prop_None, "Embedded Pat pattern file. System use only."); // n/a to end users - ADD_PROPERTY_TYPE(NameGeomPattern ,(DrawGeomHatch::prefGeomHatchName()),fgroup,App::Prop_None,"The pattern name for geometric hatching"); - ADD_PROPERTY_TYPE(HatchScale,(1.0),fgroup,App::Prop_None,"Hatch pattern size adjustment"); + ADD_PROPERTY_TYPE(NameGeomPattern ,(DrawGeomHatch::prefGeomHatchName()), fgroup, App::Prop_None, "The pattern name for geometric hatching"); + ADD_PROPERTY_TYPE(HatchScale, (1.0), fgroup, App::Prop_None, "Hatch pattern size adjustment"); getParameters(); @@ -139,8 +139,8 @@ DrawViewSection::DrawViewSection() : hatchFilter = ("PAT files (*.pat *.PAT);;All files (*)"); FileGeomPattern.setFilter(hatchFilter); - SvgIncluded.setStatus(App::Property::ReadOnly,true); - PatIncluded.setStatus(App::Property::ReadOnly,true); + SvgIncluded.setStatus(App::Property::ReadOnly, true); + PatIncluded.setStatus(App::Property::ReadOnly, true); } DrawViewSection::~DrawViewSection() @@ -238,7 +238,7 @@ App::DocumentObjectExecReturn *DrawViewSection::execute() if (FuseBeforeCut.getValue()) { baseShape = dvp->getSourceShapeFused(); } - + if (baseShape.IsNull()) { return DrawView::execute(); } @@ -308,17 +308,17 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) gp_Dir gpNormal = pln.Axis().Direction(); Base::Vector3d orgPnt = SectionOrigin.getValue(); - if(!isReallyInBox(gp_Pnt(orgPnt.x,orgPnt.y,orgPnt.z), centerBox)) { - Base::Console().Warning("DVS: SectionOrigin doesn't intersect part in %s\n",getNameInDocument()); + if(!isReallyInBox(gp_Pnt(orgPnt.x, orgPnt.y, orgPnt.z), centerBox)) { + Base::Console().Warning("DVS: SectionOrigin doesn't intersect part in %s\n", getNameInDocument()); } // make cutting tool // Make the extrusion face double dMax = sqrt(centerBox.SquareExtent()); - BRepBuilderAPI_MakeFace mkFace(pln, -dMax,dMax,-dMax,dMax); + BRepBuilderAPI_MakeFace mkFace(pln, -dMax, dMax, -dMax, dMax); TopoDS_Face aProjFace = mkFace.Face(); if(aProjFace.IsNull()) { - Base::Console().Warning("DVS: Section face is NULL in %s\n",getNameInDocument()); + Base::Console().Warning("DVS: Section face is NULL in %s\n", getNameInDocument()); return; } gp_Vec extrudeDir = dMax * gp_Vec(gpNormal); @@ -341,7 +341,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) const TopoDS_Solid& s = TopoDS::Solid(expl.Current()); BRepAlgoAPI_Cut mkCut(s, prism); if (!mkCut.IsDone()) { - Base::Console().Warning("DVS: Section cut has failed in %s\n",getNameInDocument()); + Base::Console().Warning("DVS: Section cut has failed in %s\n", getNameInDocument()); continue; } TopoDS_Shape cut = mkCut.Shape(); @@ -389,7 +389,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) m_scaledShape = TechDraw::scaleShape(centeredShape, getScale()); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { m_scaledShape = TechDraw::rotateShape(m_scaledShape, m_viewAxis, Rotation.getValue()); @@ -405,7 +405,7 @@ void DrawViewSection::makeSectionCut(TopoDS_Shape &baseShape) } catch (Standard_Failure& e1) { Base::Console().Warning("DVS::makeSectionCut - failed to build base shape %s - %s **\n", - getNameInDocument(),e1.GetMessageString()); + getNameInDocument(), e1.GetMessageString()); return; } @@ -456,7 +456,7 @@ void DrawViewSection::postHlrTasks(void) TopoDS_Shape scaledSection = TechDraw::scaleShape(centeredShapeF, getScale()); - if (!DrawUtil::fpCompare(Rotation.getValue(),0.0)) { + if (!DrawUtil::fpCompare(Rotation.getValue(), 0.0)) { scaledSection = TechDraw::rotateShape(scaledSection, m_viewAxis, Rotation.getValue()); @@ -658,7 +658,7 @@ Base::Vector3d DrawViewSection::getXDirection() const return result; } -void DrawViewSection::setCSFromBase(const std::string sectionName) +void DrawViewSection::setCSFromBase(const std::string sectionName) { // Base::Console().Message("DVS::setCSFromBase(%s)\n", sectionName.c_str()); gp_Dir gDir = getCSFromBase(sectionName).Direction(); @@ -683,7 +683,7 @@ gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const Base::Vector3d sectOrigin = SectionOrigin.getValue(); gp_Ax2 dvpCS = getBaseDVP()->getProjectionCS(sectOrigin); - + if (debugSection()) { DrawUtil::dumpCS("DVS::getCSFromBase - dvp CS", dvpCS); } @@ -709,7 +709,7 @@ gp_Ax2 DrawViewSection::getCSFromBase(const std::string sectionName) const dvsDir = dvpRight.Reversed(); dvsXDir = dvpDir; } else { - Base::Console().Log("Error - DVS::getCSFromBase - bad sectionName: %s\n",sectionName.c_str()); + Base::Console().Log("Error - DVS::getCSFromBase - bad sectionName: %s\n", sectionName.c_str()); dvsDir = dvpRight; dvsXDir = dvpDir; } @@ -744,7 +744,7 @@ gp_Ax2 DrawViewSection::getSectionCS() const gp_Ax2 sectionCS(gOrigin, gNormal); try { - sectionCS = gp_Ax2(gOrigin, + sectionCS = gp_Ax2(gOrigin, gNormal, gXDir); } @@ -758,7 +758,7 @@ std::vector DrawViewSection::getDrawableLines(int i) { // Base::Console().Message("DVS::getDrawableLines(%d) - lineSets: %d\n", i, m_lineSets.size()); std::vector result; - result = DrawGeomHatch::getTrimmedLinesSection(this,m_lineSets, + result = DrawGeomHatch::getTrimmedLinesSection(this, m_lineSets, getSectionTopoDSFace(i), HatchScale.getValue()); return result; @@ -812,7 +812,7 @@ void DrawViewSection::unsetupObject() DrawViewPart::unsetupObject(); } -void DrawViewSection::onDocumentRestored() +void DrawViewSection::onDocumentRestored() { // Base::Console().Message("DVS::onDocumentRestored()\n"); if (SvgIncluded.isEmpty()) { @@ -884,7 +884,7 @@ void DrawViewSection::setupSvgIncluded(void) special += "SvgHatch.svg"; std::string dir = doc->TransientDir.getValue(); std::string svgName = dir + special; - + //first time std::string svgInclude = SvgIncluded.getValue(); if (svgInclude.empty()) { @@ -963,7 +963,7 @@ bool DrawViewSection::debugSection(void) const Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/debug"); - return hGrp->GetBool("debugSection",false); + return hGrp->GetBool("debugSection", false); } int DrawViewSection::prefCutSurface(void) const diff --git a/src/Mod/TechDraw/App/DrawViewSection.h b/src/Mod/TechDraw/App/DrawViewSection.h index 77359588a7..4a847363fa 100644 --- a/src/Mod/TechDraw/App/DrawViewSection.h +++ b/src/Mod/TechDraw/App/DrawViewSection.h @@ -22,8 +22,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewSection_h_ -#define _DrawViewSection_h_ +#ifndef DrawViewSection_h_ +#define DrawViewSection_h_ #include diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp index 46d6189204..6f19432ca3 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.cpp @@ -61,17 +61,17 @@ DrawViewSpreadsheet::DrawViewSpreadsheet() { static const char *vgroup = "Spreadsheet"; - ADD_PROPERTY_TYPE(Source ,(nullptr),vgroup,App::Prop_None,"Spreadsheet to view"); + ADD_PROPERTY_TYPE(Source ,(nullptr), vgroup, App::Prop_None, "Spreadsheet to view"); Source.setScope(App::LinkScope::Global); - ADD_PROPERTY_TYPE(CellStart ,("A1"),vgroup,App::Prop_None,"The top left cell of the range to display"); - ADD_PROPERTY_TYPE(CellEnd ,("B2"),vgroup,App::Prop_None,"The bottom right cell of the range to display"); + ADD_PROPERTY_TYPE(CellStart ,("A1"), vgroup, App::Prop_None, "The top left cell of the range to display"); + ADD_PROPERTY_TYPE(CellEnd ,("B2"), vgroup, App::Prop_None, "The bottom right cell of the range to display"); ADD_PROPERTY_TYPE(Font ,(Preferences::labelFont().c_str()), - vgroup,App::Prop_None,"The name of the font to use"); - ADD_PROPERTY_TYPE(TextColor,(0.0f,0.0f,0.0f),vgroup,App::Prop_None,"The default color of the text and lines"); - ADD_PROPERTY_TYPE(TextSize,(12.0),vgroup,App::Prop_None,"The size of the text"); - ADD_PROPERTY_TYPE(LineWidth,(0.35),vgroup,App::Prop_None,"The thickness of the cell lines"); + vgroup, App::Prop_None, "The name of the font to use"); + ADD_PROPERTY_TYPE(TextColor, (0.0f, 0.0f, 0.0f), vgroup, App::Prop_None, "The default color of the text and lines"); + ADD_PROPERTY_TYPE(TextSize, (12.0), vgroup, App::Prop_None, "The size of the text"); + ADD_PROPERTY_TYPE(LineWidth, (0.35), vgroup, App::Prop_None, "The thickness of the cell lines"); - EditableTexts.setStatus(App::Property::Hidden,true); + EditableTexts.setStatus(App::Property::Hidden, true); } @@ -161,10 +161,10 @@ std::string DrawViewSpreadsheet::getSheetImage() std::string scellstart = CellStart.getValue(); std::string scellend = CellEnd.getValue(); - //s/s columns are A,B,C, ... ZX,ZY,ZZ + //s/s columns are A, B,C, ... ZX, ZY, ZZ //lower case characters are not valid - transform(scellstart.begin(), scellstart.end(), scellstart.begin(), ::toupper); - transform(scellend.begin(), scellend.end(), scellend.begin(), ::toupper); + transform(scellstart.begin(), scellstart.end(), scellstart.begin(), ::toupper); + transform(scellend.begin(), scellend.end(), scellend.begin(), ::toupper); std::string colPart; std::string rowPart; @@ -174,7 +174,7 @@ std::string DrawViewSpreadsheet::getSheetImage() std::string sColStart, sColEnd; if (boost::regex_search(scellstart, what, re)) { if (what.size() < 3) { - Base::Console().Error("%s - start cell (%s) is invalid\n",getNameInDocument(),CellStart.getValue()); + Base::Console().Error("%s - start cell (%s) is invalid\n", getNameInDocument(), CellStart.getValue()); return std::string(); } @@ -193,7 +193,7 @@ std::string DrawViewSpreadsheet::getSheetImage() if (boost::regex_search(scellend, what, re)) { if (what.size() < 3) { - Base::Console().Error("%s - end cell (%s) is invalid\n",getNameInDocument(),CellEnd.getValue()); + Base::Console().Error("%s - end cell (%s) is invalid\n", getNameInDocument(), CellEnd.getValue()); } else { colPart = what[1]; sColEnd = colPart; @@ -220,7 +220,7 @@ std::string DrawViewSpreadsheet::getSheetImage() } //validate range end column in sheet's available columns - int iAvailColEnd = colInList(availcolumns,sColEnd); + int iAvailColEnd = colInList(availcolumns, sColEnd); if (iAvailColEnd < 0) { Base::Console().Error("DVS - %s - end Column (%s) is invalid\n", getNameInDocument(), sColEnd.c_str()); @@ -230,7 +230,7 @@ std::string DrawViewSpreadsheet::getSheetImage() //check for logical range if ( (iAvailColStart > iAvailColEnd) || (iRowStart > iRowEnd) ) { - Base::Console().Error("%s - cell range is illogical\n",getNameInDocument()); + Base::Console().Error("%s - cell range is illogical\n", getNameInDocument()); return std::string(); } @@ -242,7 +242,7 @@ std::string DrawViewSpreadsheet::getSheetImage() for (; iCol <= iAvailColEnd; iCol++) { validColNames.push_back(availcolumns.at(iCol)); } - + int iRow = iRowStart; for ( ; iRow <= iRowEnd ; iRow++) { validRowNumbers.push_back(iRow); @@ -301,7 +301,7 @@ std::string DrawViewSpreadsheet::getSheetImage() std::string fcolor = c.asHexString(); std::string textstyle; if (cell) { - App::Color f,b; + App::Color f, b; std::set st; int colspan, rowspan; if (cell->getBackground(b)) { @@ -320,10 +320,10 @@ std::string DrawViewSpreadsheet::getSheetImage() textstyle = textstyle + "text-decoration: underline; "; } } - if (cell->getSpans(rowspan,colspan)) { + if (cell->getSpans(rowspan, colspan)) { for (int i=0; i 0) cellwidth = cellwidth + sheet->getColumnWidth(nextcell.col()); if (j > 0) diff --git a/src/Mod/TechDraw/App/DrawViewSpreadsheet.h b/src/Mod/TechDraw/App/DrawViewSpreadsheet.h index d0e9fe8687..cb4cb55872 100644 --- a/src/Mod/TechDraw/App/DrawViewSpreadsheet.h +++ b/src/Mod/TechDraw/App/DrawViewSpreadsheet.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewSpreadsheet_h_ -#define _DrawViewSpreadsheet_h_ +#ifndef DrawViewSpreadsheet_h_ +#define DrawViewSpreadsheet_h_ #include diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.cpp b/src/Mod/TechDraw/App/DrawViewSymbol.cpp index 4d6718fb6f..4b20d90698 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawViewSymbol.cpp @@ -56,10 +56,10 @@ DrawViewSymbol::DrawViewSymbol() { static const char *vgroup = "Drawing view"; - ADD_PROPERTY_TYPE(Symbol,(""),vgroup,App::Prop_None,"The SVG code defining this symbol"); - ADD_PROPERTY_TYPE(EditableTexts,(""),vgroup,App::Prop_None,"Substitution values for the editable strings in this symbol"); + ADD_PROPERTY_TYPE(Symbol, (""), vgroup, App::Prop_None, "The SVG code defining this symbol"); + ADD_PROPERTY_TYPE(EditableTexts, (""), vgroup, App::Prop_None, "Substitution values for the editable strings in this symbol"); ScaleType.setValue("Custom"); - Symbol.setStatus(App::Property::Hidden,true); + Symbol.setStatus(App::Property::Hidden, true); } DrawViewSymbol::~DrawViewSymbol() @@ -94,7 +94,7 @@ QRectF DrawViewSymbol::getRect() const { double w = 64.0; //must default to something double h = 64.0; - return (QRectF(0,0,w,h)); + return (QRectF(0, 0,w, h)); } //!Assume all svg files fit the page and/or the user will scale manually @@ -209,7 +209,7 @@ PyObject *DrawViewSymbol::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawViewSymbolPy(this),true); + PythonObject = Py::Object(new DrawViewSymbolPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawViewSymbol.h b/src/Mod/TechDraw/App/DrawViewSymbol.h index a8cced9aba..873358ae99 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbol.h +++ b/src/Mod/TechDraw/App/DrawViewSymbol.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawViewSymbol_h_ -#define _DrawViewSymbol_h_ +#ifndef DrawViewSymbol_h_ +#define DrawViewSymbol_h_ #include diff --git a/src/Mod/TechDraw/App/DrawViewSymbolPyImp.cpp b/src/Mod/TechDraw/App/DrawViewSymbolPyImp.cpp index 9e03f7dd7a..c891c153f8 100644 --- a/src/Mod/TechDraw/App/DrawViewSymbolPyImp.cpp +++ b/src/Mod/TechDraw/App/DrawViewSymbolPyImp.cpp @@ -57,7 +57,7 @@ PyObject* DrawViewSymbolPy::dumpSymbol(PyObject *args) Base::FileInfo fi(fileSpec); Base::ofstream outfile; outfile.open(fi); - outfile.write (symbolRepr.c_str(),symbolRepr.size()); + outfile.write (symbolRepr.c_str(), symbolRepr.size()); outfile.close(); if (outfile.good()) { outfile.close(); diff --git a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp index 7c503b03b1..bb7ed9644d 100644 --- a/src/Mod/TechDraw/App/DrawWeldSymbol.cpp +++ b/src/Mod/TechDraw/App/DrawWeldSymbol.cpp @@ -53,22 +53,18 @@ DrawWeldSymbol::DrawWeldSymbol() { static const char *group = "Weld Symbol"; - ADD_PROPERTY_TYPE(Leader,(nullptr),group,(App::PropertyType)(App::Prop_None), "Parent Leader"); + ADD_PROPERTY_TYPE(Leader, (nullptr), group, (App::PropertyType)(App::Prop_None), "Parent Leader"); ADD_PROPERTY_TYPE(AllAround, (false), group, App::Prop_None, "All Around Symbol on/off"); ADD_PROPERTY_TYPE(FieldWeld, (false), group, App::Prop_None, "Field Weld Symbol on/off"); ADD_PROPERTY_TYPE(AlternatingWeld, (false), group, App::Prop_None, "Alternating Weld true/false"); ADD_PROPERTY_TYPE(TailText, (""), group, App::Prop_None, "Text at tail of symbol"); - Caption.setStatus(App::Property::Hidden,true); - Scale.setStatus(App::Property::Hidden,true); - ScaleType.setStatus(App::Property::Hidden,true); + Caption.setStatus(App::Property::Hidden, true); + Scale.setStatus(App::Property::Hidden, true); + ScaleType.setStatus(App::Property::Hidden, true); Rotation.setStatus(App::Property::Hidden, true); } -DrawWeldSymbol::~DrawWeldSymbol() -{ -} - //DWS always has exactly 2 child tiles - ArrowSide and OtherSide. //OtherSide tile may be hidden; //once DWS has been added to the document, add 2x DrawTileWeld @@ -122,7 +118,7 @@ App::DocumentObjectExecReturn *DrawWeldSymbol::execute() if (!keepUpdated()) { return DrawView::execute(); } - + overrideKeepUpdated(false); return DrawView::execute(); } @@ -166,7 +162,7 @@ PyObject *DrawWeldSymbol::getPyObject() { if (PythonObject.is(Py::_None())) { // ref counter is set to 1 - PythonObject = Py::Object(new DrawWeldSymbolPy(this),true); + PythonObject = Py::Object(new DrawWeldSymbolPy(this), true); } return Py::new_reference_to(PythonObject); } diff --git a/src/Mod/TechDraw/App/DrawWeldSymbol.h b/src/Mod/TechDraw/App/DrawWeldSymbol.h index 153aec9f03..b46567d635 100644 --- a/src/Mod/TechDraw/App/DrawWeldSymbol.h +++ b/src/Mod/TechDraw/App/DrawWeldSymbol.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_DrawWeldSymbol_h_ -#define _TechDraw_DrawWeldSymbol_h_ +#ifndef TechDraw_DrawWeldSymbol_h_ +#define TechDraw_DrawWeldSymbol_h_ #include @@ -42,7 +42,7 @@ class TechDrawExport DrawWeldSymbol : public TechDraw::DrawView public: DrawWeldSymbol(); - ~DrawWeldSymbol() override; + ~DrawWeldSymbol() = default; App::PropertyLink Leader; App::PropertyBool AllAround; @@ -58,7 +58,7 @@ public: return "TechDrawGui::ViewProviderWeld"; } PyObject *getPyObject() override; - QRectF getRect() const override { return QRectF(0,0,1,1);} + QRectF getRect() const override { return { 0, 0, 1, 1}; } bool isTailRightSide(); std::vector getTiles() const; diff --git a/src/Mod/TechDraw/App/EdgeWalker.cpp b/src/Mod/TechDraw/App/EdgeWalker.cpp index 1541c18996..5aa27ecbae 100644 --- a/src/Mod/TechDraw/App/EdgeWalker.cpp +++ b/src/Mod/TechDraw/App/EdgeWalker.cpp @@ -62,14 +62,14 @@ using namespace boost; template void edgeVisitor::next_edge(Edge e) { - graph_traits::vertex_descriptor s = source(e,m_g); - graph_traits::vertex_descriptor t = target(e,m_g); + graph_traits::vertex_descriptor s = source(e, m_g); + graph_traits::vertex_descriptor t = target(e, m_g); WalkerEdge we; we.v1 = s; we.v2 = t; we.ed = e; - we.idx = get(edge_index,m_g,e); - //Base::Console().Message("TRACE - EV::next_Edge - visiting (%d,%d) idx: %d\n",s,t,we.idx); + we.idx = get(edge_index, m_g, e); + //Base::Console().Message("TRACE - EV::next_Edge - visiting (%d, %d) idx: %d\n", s,t, we.idx); wireEdges.push_back(we); } @@ -118,8 +118,8 @@ bool EdgeWalker::loadEdges(std::vector& edges) //Base::Console().Message("TRACE -EW::loadEdges(we)\n"); int idx = 0; for (auto& e: edges) { - std::pair p; - p = add_edge(e.v1,e.v2,m_g); + std::pair p; + p = add_edge(e.v1, e.v2, m_g); e.ed = p.first; e.idx = idx; idx++; @@ -142,7 +142,7 @@ bool EdgeWalker::loadEdges(std::vector edges) std::vector we = makeWalkerEdges(edges, verts); loadEdges(we); - m_embedding = makeEmbedding(edges,verts); + m_embedding = makeEmbedding(edges, verts); return true; } @@ -204,10 +204,10 @@ bool EdgeWalker::perform() ss << "EW::perform - obstructing edges: "; for(ki = kEdges.begin(); ki != ki_end; ++ki) { e1 = *ki; - ss << boost::get(edge_index,m_g,e1) << ","; + ss << boost::get(edge_index, m_g, e1) << ", "; } ss << std::endl; - Base::Console().Log("LOG - %s\n",ss.str().c_str()); + Base::Console().Log("LOG - %s\n", ss.str().c_str()); return false; } @@ -316,9 +316,9 @@ std::vector EdgeWalker:: makeUniqueVList(std::vector bool addv1 = true; bool addv2 = true; for (const auto& v:uniqueVert) { - if (DrawUtil::isSamePoint(v,v1,EWTOLERANCE)) + if (DrawUtil::isSamePoint(v, v1, EWTOLERANCE)) addv1 = false; - if (DrawUtil::isSamePoint(v,v2,EWTOLERANCE)) + if (DrawUtil::isSamePoint(v, v2, EWTOLERANCE)) addv2 = false; } if (addv1) @@ -348,7 +348,7 @@ std::vector EdgeWalker::makeWalkerEdges(std::vector edg walkerEdges.push_back(we); } - //Base::Console().Message("TRACE - EW::makeWalkerEdges - returns we: %d\n",walkerEdges.size()); + //Base::Console().Message("TRACE - EW::makeWalkerEdges - returns we: %d\n", walkerEdges.size()); return walkerEdges; } @@ -358,7 +358,7 @@ int EdgeWalker::findUniqueVert(TopoDS_Vertex vx, std::vector &uni int idx = 0; int result = 0; for(auto& v:uniqueVert) { //we're always going to find vx, right? - if (DrawUtil::isSamePoint(v,vx,EWTOLERANCE)) { + if (DrawUtil::isSamePoint(v, vx, EWTOLERANCE)) { result = idx; break; } @@ -375,7 +375,7 @@ std::vector EdgeWalker::sortStrip(std::vector fw, bool closedWires.push_back(w); } } - std::vector sortedWires = sortWiresBySize(closedWires,false); //biggest 1st + std::vector sortedWires = sortWiresBySize(closedWires, false); //biggest 1st if (sortedWires.empty()) { Base::Console().Log("INFO - EW::sortStrip - no sorted Wires!\n"); return sortedWires; // might happen in the middle of changes? @@ -395,7 +395,7 @@ std::vector EdgeWalker::sortWiresBySize(std::vector& w std::vector wires = w; std::sort(wires.begin(), wires.end(), EdgeWalker::wireCompare); if (ascend) { - std::reverse(wires.begin(),wires.end()); + std::reverse(wires.begin(), wires.end()); } return wires; } @@ -412,7 +412,7 @@ std::vector EdgeWalker::makeEmbedding(const std::vector const std::vector uniqueVList) { // Base::Console().Message("TRACE - EW::makeEmbedding(edges: %d, verts: %d)\n", -// edges.size(),uniqueVList.size()); +// edges.size(), uniqueVList.size()); std::vector result; int iv = 0; @@ -421,12 +421,12 @@ std::vector EdgeWalker::makeEmbedding(const std::vector std::vector iiList; for (auto& e: edges) { double angle = 0; - if (DrawUtil::isFirstVert(e,v,EWTOLERANCE)) { - angle = DrawUtil::angleWithX(e,v,EWTOLERANCE); + if (DrawUtil::isFirstVert(e, v,EWTOLERANCE)) { + angle = DrawUtil::angleWithX(e, v,EWTOLERANCE); incidenceItem ii(ie, angle, m_saveWalkerEdges[ie].ed); iiList.push_back(ii); - } else if (DrawUtil::isLastVert(e,v,EWTOLERANCE)) { - angle = DrawUtil::angleWithX(e,v,EWTOLERANCE); + } else if (DrawUtil::isLastVert(e, v,EWTOLERANCE)) { + angle = DrawUtil::angleWithX(e, v,EWTOLERANCE); incidenceItem ii(ie, angle, m_saveWalkerEdges[ie].ed); iiList.push_back(ii); } else { @@ -446,7 +446,7 @@ std::vector EdgeWalker::makeEmbedding(const std::vector //! get incidence row as edge indices for v'th vertex std::vector EdgeWalker::getEmbeddingRowIx(int v) { -// //Base::Console().Message("TRACE - EW::getEmbeddingRowIx(%d)\n",v); +// //Base::Console().Message("TRACE - EW::getEmbeddingRowIx(%d)\n", v); std::vector result; embedItem ei = m_embedding[v]; for (auto& ii: ei.incidenceList) { @@ -458,7 +458,7 @@ std::vector EdgeWalker::getEmbeddingRowIx(int v) //! get incidence row as edgeDescriptors for v'th vertex std::vector EdgeWalker::getEmbeddingRow(int v) { -// //Base::Console().Message("TRACE - EW::getEmbeddingRow(%d)\n",v); +// //Base::Console().Message("TRACE - EW::getEmbeddingRow(%d)\n", v); std::vector result; embedItem ei = m_embedding[v]; for (auto& ii: ei.incidenceList) { @@ -506,8 +506,8 @@ bool ewWire::isEqual(ewWire w2) if (wedges.size() != w2.wedges.size()) { result = false; } else { - std::sort(wedges.begin(),wedges.end(),WalkerEdge::weCompare); - std::sort(w2.wedges.begin(),w2.wedges.end(),WalkerEdge::weCompare); + std::sort(wedges.begin(), wedges.end(), WalkerEdge::weCompare); + std::sort(w2.wedges.begin(), w2.wedges.end(), WalkerEdge::weCompare); for (unsigned int i = 0; i < w2.wedges.size(); i ++) { if (wedges.at(i).idx != w2.wedges.at(i).idx) { result = false; @@ -587,7 +587,7 @@ std::vector embedItem::sortIncidenceList (std::vector tempList = list; std::sort(tempList.begin(), tempList.end(), incidenceItem::iiCompare); if (ascend) { - std::reverse(tempList.begin(),tempList.end()); + std::reverse(tempList.begin(), tempList.end()); } return tempList; } diff --git a/src/Mod/TechDraw/App/EdgeWalker.h b/src/Mod/TechDraw/App/EdgeWalker.h index 9108018218..e62668eafb 100644 --- a/src/Mod/TechDraw/App/EdgeWalker.h +++ b/src/Mod/TechDraw/App/EdgeWalker.h @@ -125,7 +125,7 @@ class TechDrawExport incidenceItem public: incidenceItem() {iEdge = 0; angle = 0.0;} incidenceItem(int idx, double a, edge_t ed) {iEdge = idx; angle = a; eDesc = ed;} - ~incidenceItem() {} + ~incidenceItem() = default; static bool iiCompare(const incidenceItem& i1, const incidenceItem& i2); static bool iiEqual(const incidenceItem& i1, const incidenceItem& i2); int iEdge; @@ -139,7 +139,7 @@ public: embedItem(); embedItem(int i, std::vector list) { iVertex = i; incidenceList = list;} - ~embedItem() {} + ~embedItem() = default; int iVertex; std::vector incidenceList; diff --git a/src/Mod/TechDraw/App/FeatureProjection.cpp b/src/Mod/TechDraw/App/FeatureProjection.cpp index 8e2e8f19d0..7301c978d7 100644 --- a/src/Mod/TechDraw/App/FeatureProjection.cpp +++ b/src/Mod/TechDraw/App/FeatureProjection.cpp @@ -50,18 +50,18 @@ PROPERTY_SOURCE(TechDraw::FeatureProjection, Part::Feature) FeatureProjection::FeatureProjection() { static const char *group = "Projection"; - ADD_PROPERTY_TYPE(Source ,(nullptr),group,App::Prop_None,"Shape to project"); - ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0,0,1)),group,App::Prop_None,"Projection direction"); - ADD_PROPERTY_TYPE(VCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(RgNLineVCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(OutLineVCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(IsoLineVCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(HCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(Rg1LineHCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(RgNLineHCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(OutLineHCompound ,(true),group,App::Prop_None,"Projection parameter"); - ADD_PROPERTY_TYPE(IsoLineHCompound ,(true),group,App::Prop_None,"Projection parameter"); + ADD_PROPERTY_TYPE(Source ,(nullptr), group, App::Prop_None, "Shape to project"); + ADD_PROPERTY_TYPE(Direction ,(Base::Vector3d(0, 0,1)), group, App::Prop_None, "Projection direction"); + ADD_PROPERTY_TYPE(VCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(Rg1LineVCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(RgNLineVCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(OutLineVCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(IsoLineVCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(HCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(Rg1LineHCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(RgNLineHCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(OutLineHCompound ,(true), group, App::Prop_None, "Projection parameter"); + ADD_PROPERTY_TYPE(IsoLineHCompound ,(true), group, App::Prop_None, "Projection parameter"); } FeatureProjection::~FeatureProjection() diff --git a/src/Mod/TechDraw/App/Geometry.cpp b/src/Mod/TechDraw/App/Geometry.cpp index 1f98f3ffeb..70d44a2f0e 100644 --- a/src/Mod/TechDraw/App/Geometry.cpp +++ b/src/Mod/TechDraw/App/Geometry.cpp @@ -215,21 +215,21 @@ BaseGeomPtr BaseGeom::copy() result->sourceIndex(m_sourceIndex); result->cosmeticTag = cosmeticTag; } - + return result; } std::string BaseGeom::toString() const { std::stringstream ss; - ss << geomType << "," << - extractType << "," << - classOfEdge << "," << - hlrVisible << "," << - reversed << "," << - ref3D << "," << - cosmetic << "," << - m_source << "," << + ss << geomType << ", " << + extractType << ", " << + classOfEdge << ", " << + hlrVisible << ", " << + reversed << ", " << + ref3D << ", " << + cosmetic << ", " << + m_source << ", " << m_sourceIndex; return ss.str(); } @@ -293,9 +293,9 @@ std::vector BaseGeom::findEndPoints() if (!occEdge.IsNull()) { gp_Pnt p = BRep_Tool::Pnt(TopExp::FirstVertex(occEdge)); - result.emplace_back(p.X(),p.Y(), p.Z()); + result.emplace_back(p.X(), p.Y(), p.Z()); p = BRep_Tool::Pnt(TopExp::LastVertex(occEdge)); - result.emplace_back(p.X(),p.Y(), p.Z()); + result.emplace_back(p.X(), p.Y(), p.Z()); } else { //TODO: this should throw something Base::Console().Message("Geometry::findEndPoints - OCC edge not found\n"); @@ -367,24 +367,24 @@ std::vector BaseGeom::getQuads() double q1 = u + (range / 4.0); double q2 = u + (range / 2.0); double q3 = u + (3.0 * range / 4.0); - BRepLProp_CLProps prop(adapt,q1,0,Precision::Confusion()); + BRepLProp_CLProps prop(adapt, q1, 0,Precision::Confusion()); const gp_Pnt& p1 = prop.Value(); - result.emplace_back(p1.X(),p1.Y(), 0.0); + result.emplace_back(p1.X(), p1.Y(), 0.0); prop.SetParameter(q2); const gp_Pnt& p2 = prop.Value(); - result.emplace_back(p2.X(),p2.Y(), 0.0); + result.emplace_back(p2.X(), p2.Y(), 0.0); prop.SetParameter(q3); const gp_Pnt& p3 = prop.Value(); - result.emplace_back(p3.X(),p3.Y(), 0.0); + result.emplace_back(p3.X(), p3.Y(), 0.0); return result; } double BaseGeom::minDist(Base::Vector3d p) { double minDist = -1.0; - gp_Pnt pnt(p.x,p.y,0.0); + gp_Pnt pnt(p.x, p.y, 0.0); TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt); - minDist = TechDraw::DrawUtil::simpleMinDist(occEdge,v); + minDist = TechDraw::DrawUtil::simpleMinDist(occEdge, v); return minDist; } @@ -407,8 +407,8 @@ Base::Vector3d BaseGeom::nearPoint(const BaseGeomPtr p) Base::Vector3d BaseGeom::nearPoint(Base::Vector3d p) { - gp_Pnt pnt(p.x,p.y,0.0); - Base::Vector3d result(0.0,0.0, 0.0); + gp_Pnt pnt(p.x, p.y, 0.0); + Base::Vector3d result(0.0, 0.0, 0.0); TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt); BRepExtrema_DistShapeShape extss(occEdge, v); if (extss.IsDone()) { @@ -416,7 +416,7 @@ Base::Vector3d BaseGeom::nearPoint(Base::Vector3d p) if (count != 0) { gp_Pnt p1; p1 = extss.PointOnShape1(1); - result = Base::Vector3d(p1.X(),p1.Y(), 0.0); + result = Base::Vector3d(p1.X(), p1.Y(), 0.0); } } return result; @@ -427,7 +427,7 @@ std::string BaseGeom::dump() Base::Vector3d start = getStartPoint(); Base::Vector3d end = getEndPoint(); std::stringstream ss; - ss << "BaseGeom: s:(" << start.x << "," << start.y << ") e:(" << end.x << "," << end.y << ") "; + ss << "BaseGeom: s:(" << start.x << ", " << start.y << ") e:(" << end.x << ", " << end.y << ") "; ss << "type: " << geomType << " class: " << classOfEdge << " viz: " << hlrVisible << " rev: " << reversed; ss << "cosmetic: " << cosmetic << " source: " << source() << " iSource: " << sourceIndex(); return ss.str(); @@ -498,7 +498,7 @@ BaseGeomPtr BaseGeom::baseFactory(TopoDS_Edge edge) result->reversed = true; } - // OCC is quite happy with Degree > 3 but QtGui handles only 2,3 + // OCC is quite happy with Degree > 3 but QtGui handles only 2, 3 } break; case GeomAbs_BSplineCurve: { TopoDS_Edge circEdge; @@ -736,7 +736,7 @@ Ellipse::Ellipse(Base::Vector3d c, double mnr, double mjr) minor = mnr; angle = 0; - GC_MakeEllipse me(gp_Ax2(gp_Pnt(c.x,c.y,c.z), gp_Dir(0.0,0.0,1.0)), + GC_MakeEllipse me(gp_Ax2(gp_Pnt(c.x, c.y, c.z), gp_Dir(0.0, 0.0, 1.0)), major, minor); if (!me.IsDone()) { Base::Console().Message("G:Ellipse - failed to make Ellipse\n"); @@ -761,18 +761,18 @@ AOE::AOE(const TopoDS_Edge &e) : Ellipse(e) double a; try { - gp_Vec v1(m,s); - gp_Vec v2(m,ePt); - gp_Vec v3(0,0,1); - a = v3.DotCross(v1,v2); + gp_Vec v1(m, s); + gp_Vec v2(m, ePt); + gp_Vec v3(0, 0,1); + a = v3.DotCross(v1, v2); } catch (const Standard_Failure& e) { Base::Console().Error("Geom::AOE::AOE - OCC error - %s - while making AOE in ctor\n", e.GetMessageString()); } - startAngle = fmod(f,2.0*M_PI); - endAngle = fmod(l,2.0*M_PI); + startAngle = fmod(f, 2.0*M_PI); + endAngle = fmod(l, 2.0*M_PI); cw = (a < 0) ? true: false; largeArc = (l-f > M_PI) ? true : false; @@ -798,7 +798,7 @@ Circle::Circle(Base::Vector3d c, double r) radius = r; center = c; gp_Pnt loc(c.x, c.y, c.z); - gp_Dir dir(0,0,1); + gp_Dir dir(0, 0,1); gp_Ax1 axis(loc, dir); gp_Circ circle; circle.SetAxis(axis); @@ -829,11 +829,11 @@ std::string Circle::toString() const { std::string baseCSV = BaseGeom::toString(); std::stringstream ss; - ss << center.x << "," << - center.y << "," << - center.z << "," << + ss << center.x << ", " << + center.y << ", " << + center.z << ", " << radius; - return baseCSV + ",$$$," + ss.str(); + return baseCSV + ", $$$, " + ss.str(); } void Circle::Save(Base::Writer &writer) const @@ -872,13 +872,13 @@ AOC::AOC(const TopoDS_Edge &e) : Circle(e) gp_Pnt s = c.Value(f); gp_Pnt m = c.Value((l+f)/2.0); gp_Pnt ePt = c.Value(l); //if start == end, it isn't an arc! - gp_Vec v1(m,s); //vector mid to start - gp_Vec v2(m,ePt); //vector mid to end - gp_Vec v3(0,0,1); //stdZ - double a = v3.DotCross(v1,v2); //error if v1 = v2? + gp_Vec v1(m, s); //vector mid to start + gp_Vec v2(m, ePt); //vector mid to end + gp_Vec v3(0, 0,1); //stdZ + double a = v3.DotCross(v1, v2); //error if v1 = v2? - startAngle = fmod(f,2.0*M_PI); - endAngle = fmod(l,2.0*M_PI); + startAngle = fmod(f, 2.0*M_PI); + endAngle = fmod(l, 2.0*M_PI); cw = (a < 0) ? true: false; largeArc = (fabs(l-f) > M_PI) ? true : false; @@ -897,7 +897,7 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle() radius = r; center = c; gp_Pnt loc(c.x, c.y, c.z); - gp_Dir dir(0,0,1); + gp_Dir dir(0, 0,1); gp_Ax1 axis(loc, dir); gp_Circ circle; circle.SetAxis(axis); @@ -915,13 +915,13 @@ AOC::AOC(Base::Vector3d c, double r, double sAng, double eAng) : Circle() gp_Pnt s = adp.Value(f); gp_Pnt m = adp.Value((l+f)/2.0); gp_Pnt ePt = adp.Value(l); //if start == end, it isn't an arc! - gp_Vec v1(m,s); //vector mid to start - gp_Vec v2(m,ePt); //vector mid to end - gp_Vec v3(0,0,1); //stdZ - double a = v3.DotCross(v1,v2); //error if v1 = v2? + gp_Vec v1(m, s); //vector mid to start + gp_Vec v2(m, ePt); //vector mid to end + gp_Vec v3(0, 0,1); //stdZ + double a = v3.DotCross(v1, v2); //error if v1 = v2? - startAngle = fmod(f,2.0*M_PI); - endAngle = fmod(l,2.0*M_PI); + startAngle = fmod(f, 2.0*M_PI); + endAngle = fmod(l, 2.0*M_PI); cw = (a < 0) ? true: false; largeArc = (fabs(l-f) > M_PI) ? true : false; @@ -952,7 +952,7 @@ bool AOC::isOnArc(Base::Vector3d p) { bool result = false; double minDist = -1.0; - gp_Pnt pnt(p.x,p.y,p.z); + gp_Pnt pnt(p.x, p.y, p.z); TopoDS_Vertex v = BRepBuilderAPI_MakeVertex(pnt); BRepExtrema_DistShapeShape extss(occEdge, v); if (extss.IsDone()) { @@ -979,11 +979,11 @@ bool AOC::intersectsArc(Base::Vector3d p1, Base::Vector3d p2) { bool result = false; double minDist = -1.0; - gp_Pnt pnt1(p1.x,p1.y,p1.z); + gp_Pnt pnt1(p1.x, p1.y, p1.z); TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnt1); - gp_Pnt pnt2(p2.x,p2.y,p2.z); + gp_Pnt pnt2(p2.x, p2.y, p2.z); TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnt2); - BRepBuilderAPI_MakeEdge mkEdge(v1,v2); + BRepBuilderAPI_MakeEdge mkEdge(v1, v2); TopoDS_Edge line = mkEdge.Edge(); BRepExtrema_DistShapeShape extss(occEdge, line); if (extss.IsDone()) { @@ -1003,21 +1003,21 @@ std::string AOC::toString() const std::string circleCSV = Circle::toString(); std::stringstream ss; - ss << startPnt.x << "," << - startPnt.y << "," << - startPnt.z << "," << - endPnt.x << "," << - endPnt.y << "," << - endPnt.z << "," << - midPnt.x << "," << - midPnt.y << "," << - midPnt.z << "," << - startAngle << "," << - endAngle << "," << - cw << "," << + ss << startPnt.x << ", " << + startPnt.y << ", " << + startPnt.z << ", " << + endPnt.x << ", " << + endPnt.y << ", " << + endPnt.z << ", " << + midPnt.x << ", " << + midPnt.y << ", " << + midPnt.z << ", " << + startAngle << ", " << + endAngle << ", " << + cw << ", " << largeArc; - std::string result = circleCSV + ",$$$," + ss.str(); + std::string result = circleCSV + ", $$$, " + ss.str(); return result; } @@ -1110,22 +1110,22 @@ std::string Generic::toString() const { std::string baseCSV = BaseGeom::toString(); std::stringstream ss; - ss << points.size() << ","; + ss << points.size() << ", "; for (auto& p: points) { - ss << p.x << "," << - p.y << "," << - p.z << ","; + ss << p.x << ", " << + p.y << ", " << + p.z << ", "; } std::string genericCSV = ss.str(); genericCSV.pop_back(); - return baseCSV + ",$$$," + genericCSV; + return baseCSV + ", $$$, " + genericCSV; } void Generic::Save(Base::Writer &writer) const { BaseGeom::Save(writer); - writer.Stream() << writer.ind() + writer.Stream() << writer.ind() << "" << endl; writer.incInd(); for (auto& p: points) { @@ -1205,7 +1205,7 @@ BSpline::BSpline(const TopoDS_Edge &e) occEdge = e; Handle(Geom_BSplineCurve) spline; - double f,l; + double f, l; f = c.FirstParameter(); l = c.LastParameter(); gp_Pnt s = c.Value(f); @@ -1214,17 +1214,17 @@ BSpline::BSpline(const TopoDS_Edge &e) startPnt = Base::Vector3d(s.X(), s.Y(), s.Z()); endPnt = Base::Vector3d(ePt.X(), ePt.Y(), ePt.Z()); midPnt = Base::Vector3d(m.X(), m.Y(), m.Z()); - gp_Vec v1(m,s); - gp_Vec v2(m,ePt); - gp_Vec v3(0,0,1); - double a = v3.DotCross(v1,v2); + gp_Vec v1(m, s); + gp_Vec v2(m, ePt); + gp_Vec v3(0, 0,1); + double a = v3.DotCross(v1, v2); cw = (a < 0) ? true: false; - startAngle = atan2(startPnt.y,startPnt.x); + startAngle = atan2(startPnt.y, startPnt.x); if (startAngle < 0) { startAngle += 2.0 * M_PI; } - endAngle = atan2(endPnt.y,endPnt.x); + endAngle = atan2(endPnt.y, endPnt.x); if (endAngle < 0) { endAngle += 2.0 * M_PI; } @@ -1246,12 +1246,12 @@ BSpline::BSpline(const TopoDS_Edge &e) l = c.LastParameter(); s = c.Value(f); ePt = c.Value(l); - Base::Console().Log("Error - Geometry::BSpline - no result- from:(%.3f,%.3f) to:(%.3f,%.3f) poles: %d\n", - s.X(),s.Y(),ePt.X(),ePt.Y(),spline->NbPoles()); - TColgp_Array1OfPnt controlPoints(0,1); - controlPoints.SetValue(0,s); - controlPoints.SetValue(1,ePt); - spline = GeomAPI_PointsToBSpline(controlPoints,1).Curve(); + Base::Console().Log("Error - Geometry::BSpline - no result- from:(%.3f, %.3f) to:(%.3f, %.3f) poles: %d\n", + s.X(), s.Y(), ePt.X(), ePt.Y(), spline->NbPoles()); + TColgp_Array1OfPnt controlPoints(0, 1); + controlPoints.SetValue(0, s); + controlPoints.SetValue(1, ePt); + spline = GeomAPI_PointsToBSpline(controlPoints, 1).Curve(); } } @@ -1291,14 +1291,14 @@ bool BSpline::isLine() gp_Pnt s = c.Value(f); gp_Pnt e = c.Value(l); - bool samePnt = s.IsEqual(e,FLT_EPSILON); + bool samePnt = s.IsEqual(e, FLT_EPSILON); if (!samePnt) { Base::Vector3d vs = DrawUtil::gpPnt2V3(s); Base::Vector3d ve = DrawUtil::gpPnt2V3(e); double endLength = (vs - ve).Length(); int low = 0; int high = spline->NbPoles() - 1; - TColgp_Array1OfPnt poles(low,high); + TColgp_Array1OfPnt poles(low, high); spline->Poles(poles); double lenTotal = 0.0; for (int i = 0; i < high; i++) { @@ -1309,7 +1309,7 @@ bool BSpline::isLine() lenTotal += (v2-v1).Length(); } - if (DrawUtil::fpCompare(lenTotal,endLength)) { + if (DrawUtil::fpCompare(lenTotal, endLength)) { result = true; } } @@ -1323,7 +1323,7 @@ bool BSpline::isCircle() double radius; Base::Vector3d center; bool isArc = false; - getCircleParms(result,radius,center,isArc); + getCircleParms(result, radius, center, isArc); return result; } @@ -1333,7 +1333,7 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen double curveLimit = 0.0001; BRepAdaptor_Curve c(occEdge); Handle(Geom_BSplineCurve) spline = c.BSpline(); - double f,l; + double f, l; f = c.FirstParameter(); l = c.LastParameter(); double parmRange = fabs(l - f); @@ -1345,12 +1345,12 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen double sumCurvature = 0; Base::Vector3d sumCenter, valueAt; try { - GeomLProp_CLProps prop(spline,f,3,Precision::Confusion()); + GeomLProp_CLProps prop(spline, f,3, Precision::Confusion()); curvatures.push_back(prop.Curvature()); sumCurvature += prop.Curvature(); prop.CentreOfCurvature(curveCenter); centers.push_back(curveCenter); - sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z()); + sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z()); for (int i = 1; i < (testCount - 1); i++) { prop.SetParameter(parmStep * i); @@ -1358,14 +1358,14 @@ void BSpline::getCircleParms(bool& isCircle, double& radius, Base::Vector3d& cen sumCurvature += prop.Curvature(); prop.CentreOfCurvature(curveCenter); centers.push_back(curveCenter); - sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z()); + sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z()); } prop.SetParameter(l); curvatures.push_back(prop.Curvature()); sumCurvature += prop.Curvature(); prop.CentreOfCurvature(curveCenter); centers.push_back(curveCenter); - sumCenter += Base::Vector3d(curveCenter.X(),curveCenter.Y(),curveCenter.Z()); + sumCenter += Base::Vector3d(curveCenter.X(), curveCenter.Y(), curveCenter.Z()); } catch (Standard_Failure&) { Base::Console().Log("TechDraw - GEO::BSpline::getCircleParms - CLProps failed\n"); @@ -1428,7 +1428,7 @@ TopoDS_Edge BSpline::asCircle(bool& arc) gp_Pnt p2 = spline->Pole(nb_poles-1); gp_Pnt pm; if (nb_poles == 5) { - pm = spline->Pole(3); //5 poles => 2.5 => 2 + pm = spline->Pole(3); //5 poles => 2.5 => 2 } else { pm = spline->Pole(nb_poles / 2); } @@ -1456,16 +1456,16 @@ TopoDS_Edge BSpline::asCircle(bool& arc) pcm = projm.NearestPoint(); // make 2 circles and find their radii - gce_MakeCirc gce_circ1 = gce_MakeCirc(s,pc1,pcm); //3 point circle + gce_MakeCirc gce_circ1 = gce_MakeCirc(s, pc1, pcm); //3 point circle if (gce_circ1.Status() != gce_Done) { return result; } gp_Circ circle1 = gce_circ1.Value(); double radius1 = circle1.Radius(); - gp_Pnt center1 = circle1.Location(); + gp_Pnt center1 = circle1.Location(); Base::Vector3d vc1 = DrawUtil::gpPnt2V3(center1); - gce_MakeCirc gce_circ2 = gce_MakeCirc(pcm,pc2,e); + gce_MakeCirc gce_circ2 = gce_MakeCirc(pcm, pc2, e); if (gce_circ2.Status() != gce_Done) { return result; } @@ -1478,19 +1478,19 @@ TopoDS_Edge BSpline::asCircle(bool& arc) double allowError = 0.001; //mm^-3 good enough for printing double radius; Base::Vector3d center; - if ( (DrawUtil::fpCompare(radius2,radius1, allowError)) && - (vc1.IsEqual(vc2,allowError)) ) { + if ( (DrawUtil::fpCompare(radius2, radius1, allowError)) && + (vc1.IsEqual(vc2, allowError)) ) { if (arc) { - GC_MakeArcOfCircle makeArc(s,pcm,e); + GC_MakeArcOfCircle makeArc(s, pcm, e); Handle(Geom_TrimmedCurve) tCurve = makeArc.Value(); BRepBuilderAPI_MakeEdge newEdge(tCurve); result = newEdge; - } else { + } else { radius = (radius1 + radius2) / 2.0; center = (vc1 + vc2) / 2.0; - gp_Pnt gCenter(center.x,center.y,center.z); - gp_Ax2 stdZ(gCenter,gp_Dir(0,0,1)); - gp_Circ newCirc(stdZ,radius); + gp_Pnt gCenter(center.x, center.y, center.z); + gp_Ax2 stdZ(gCenter, gp_Dir(0, 0,1)); + gp_Circ newCirc(stdZ, radius); BRepBuilderAPI_MakeEdge newEdge(newCirc); result = newEdge; } @@ -1511,15 +1511,15 @@ TopoDS_Edge BSpline::asCircle(bool& arc) } -bool BSpline::intersectsArc(Base::Vector3d p1,Base::Vector3d p2) +bool BSpline::intersectsArc(Base::Vector3d p1, Base::Vector3d p2) { bool result = false; double minDist = -1.0; - gp_Pnt pnt1(p1.x,p1.y,p1.z); + gp_Pnt pnt1(p1.x, p1.y, p1.z); TopoDS_Vertex v1 = BRepBuilderAPI_MakeVertex(pnt1); - gp_Pnt pnt2(p2.x,p2.y,p2.z); + gp_Pnt pnt2(p2.x, p2.y, p2.z); TopoDS_Vertex v2 = BRepBuilderAPI_MakeVertex(pnt2); - BRepBuilderAPI_MakeEdge mkEdge(v1,v2); + BRepBuilderAPI_MakeEdge mkEdge(v1, v2); TopoDS_Edge line = mkEdge.Edge(); BRepExtrema_DistShapeShape extss(occEdge, line); if (extss.IsDone()) { @@ -1544,7 +1544,7 @@ BezierSegment::BezierSegment(const TopoDS_Edge &e) poles = bez->NbPoles(); degree = bez->Degree(); if (poles > 4) { - Base::Console().Log("Warning - BezierSegment has degree > 3: %d\n",degree); + Base::Console().Log("Warning - BezierSegment has degree > 3: %d\n", degree); } for (int i = 1; i <= poles; ++i) { gp_Pnt controlPoint = bez->Pole(i); @@ -1595,7 +1595,7 @@ Vertex::Vertex(double x, double y) hlrVisible = false; ref3D = -1; //obs. never used. isCenter = false; - BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x,y,0.0)); + BRepBuilderAPI_MakeVertex mkVert(gp_Pnt(x, y,0.0)); occVertex = mkVert.Vertex(); cosmetic = false; cosmeticLink = -1; @@ -1604,7 +1604,7 @@ Vertex::Vertex(double x, double y) createNewTag(); } -Vertex::Vertex(Base::Vector3d v) : Vertex(v.x,v.y) +Vertex::Vertex(Base::Vector3d v) : Vertex(v.x, v.y) { // Base::Console().Message("V::V(%s)\n", // DrawUtil::formatVector(v).c_str()); @@ -1722,14 +1722,14 @@ void Vertex::dump(const char* title) BaseGeomPtrVector GeometryUtils::chainGeoms(BaseGeomPtrVector geoms) { BaseGeomPtrVector result; - std::vector used(geoms.size(),false); + std::vector used(geoms.size(), false); if (geoms.empty()) { return result; } if (geoms.size() == 1) { - //don't bother for single geom (circles, ellipses,etc) + //don't bother for single geom (circles, ellipses, etc) result.push_back(geoms[0]); } else { //start with first edge @@ -1802,7 +1802,7 @@ TopoDS_Edge GeometryUtils::edgeFromGeneric(TechDraw::GenericPtr g) TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::CirclePtr c) { gp_Pnt loc(c->center.x, c->center.y, c->center.z); - gp_Dir dir(0,0,1); + gp_Dir dir(0, 0,1); gp_Ax1 axis(loc, dir); gp_Circ circle; circle.SetAxis(axis); @@ -1816,7 +1816,7 @@ TopoDS_Edge GeometryUtils::edgeFromCircle(TechDraw::CirclePtr c) TopoDS_Edge GeometryUtils::edgeFromCircleArc(TechDraw::AOCPtr c) { gp_Pnt loc(c->center.x, c->center.y, c->center.z); - gp_Dir dir(0,0,1); + gp_Dir dir(0, 0,1); gp_Ax1 axis(loc, dir); gp_Circ circle; circle.SetAxis(axis); diff --git a/src/Mod/TechDraw/App/Geometry.h b/src/Mod/TechDraw/App/Geometry.h index 079cf2f807..bd2e04fd05 100644 --- a/src/Mod/TechDraw/App/Geometry.h +++ b/src/Mod/TechDraw/App/Geometry.h @@ -240,7 +240,7 @@ class TechDrawExport AOC: public Circle bool largeArc; bool isOnArc(Base::Vector3d v); - bool intersectsArc(Base::Vector3d p1,Base::Vector3d p2); + bool intersectsArc(Base::Vector3d p1, Base::Vector3d p2); double distToArc(Base::Vector3d p); }; @@ -277,7 +277,7 @@ class TechDrawExport BSpline: public BaseGeom bool isCircle(); TopoDS_Edge asCircle(bool& isArc); void getCircleParms(bool& isCircle, double& radius, Base::Vector3d& center, bool& isArc); - bool intersectsArc(Base::Vector3d p1,Base::Vector3d p2); + bool intersectsArc(Base::Vector3d p1, Base::Vector3d p2); std::vector segments; }; @@ -329,7 +329,7 @@ class TechDrawExport Vertex explicit Vertex(const Vertex* v); Vertex(double x, double y); explicit Vertex(Base::Vector3d v); - virtual ~Vertex() {} + virtual ~Vertex() = default; virtual void Save(Base::Writer &/*writer*/) const; virtual void Restore(Base::XMLReader &/*reader*/); @@ -342,7 +342,7 @@ class TechDrawExport Vertex bool isCenter; TopoDS_Vertex occVertex; bool isEqual(const Vertex& v, double tol); - Base::Vector3d point() const { return Base::Vector3d(pnt.x,pnt.y,0.0); } + Base::Vector3d point() const { return Base::Vector3d(pnt.x, pnt.y, 0.0); } void point(Base::Vector3d v){ pnt = Base::Vector3d(v.x, v.y); } bool cosmetic; int cosmeticLink; //deprec. use cosmeticTag @@ -380,7 +380,7 @@ class TechDrawExport GeometryUtils /// Find an unused geom starts or ends at atPoint. /*! - * returns index[1:geoms.size()),reversed [true,false] + * returns index[1:geoms.size()), reversed [true, false] */ static ReturnType nextGeom( Base::Vector3d atPoint, std::vector geoms, diff --git a/src/Mod/TechDraw/App/GeometryObject.cpp b/src/Mod/TechDraw/App/GeometryObject.cpp index 81d2553d73..0ba8a8e873 100644 --- a/src/Mod/TechDraw/App/GeometryObject.cpp +++ b/src/Mod/TechDraw/App/GeometryObject.cpp @@ -334,7 +334,7 @@ void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input, { // Clear previous Geometry clear(); - + //work around for Mantis issue #3332 //if 3332 gets fixed in OCC, this will produce shifted views and will need //to be reverted. @@ -342,8 +342,8 @@ void GeometryObject::projectShapeWithPolygonAlgo(const TopoDS_Shape& input, if (!m_isPersp) { gp_Pnt gCenter = findCentroid(input, viewAxis); - Base::Vector3d motion(-gCenter.X(),-gCenter.Y(),-gCenter.Z()); - inCopy = moveShape(input,motion); + Base::Vector3d motion(-gCenter.X(), -gCenter.Y(), -gCenter.Z()); + inCopy = moveShape(input, motion); } else { BRepBuilderAPI_Copy BuilderCopy(input); inCopy = BuilderCopy.Shape(); @@ -458,7 +458,7 @@ TopoDS_Shape GeometryObject::projectFace(const TopoDS_Shape &face, //!add edges meeting filter criteria for category, visibility void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible) { -// Base::Console().Message("GO::extractGeometry(%d, %d)\n",category, hlrVisible); +// Base::Console().Message("GO::extractGeometry(%d, %d)\n", category, hlrVisible); TopoDS_Shape filtEdges; if (hlrVisible) { switch (category) { @@ -478,7 +478,7 @@ void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible) filtEdges = visIso; break; default: - Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hlrVisible edgeClass: %d\n",category); + Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hlrVisible edgeClass: %d\n", category); return; } } else { @@ -499,7 +499,7 @@ void GeometryObject::extractGeometry(edgeClass category, bool hlrVisible) filtEdges = hidIso; break; default: - Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hidden edgeClass: %d\n",category); + Base::Console().Warning("GeometryObject::ExtractGeometry - unsupported hidden edgeClass: %d\n", category); return; } } @@ -519,24 +519,24 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca BaseGeomPtr base; TopExp_Explorer edges(edgeCompound, TopAbs_EDGE); int i = 1; - for ( ; edges.More(); edges.Next(),i++) { + for ( ; edges.More(); edges.Next(), i++) { const TopoDS_Edge& edge = TopoDS::Edge(edges.Current()); if (edge.IsNull()) { - Base::Console().Log("GO::addGeomFromCompound - edge: %d is NULL\n",i); + Base::Console().Log("GO::addGeomFromCompound - edge: %d is NULL\n", i); continue; } if (DrawUtil::isZeroEdge(edge)) { - Base::Console().Log("GO::addGeomFromCompound - edge: %d is zeroEdge\n",i); + Base::Console().Log("GO::addGeomFromCompound - edge: %d is zeroEdge\n", i); continue; } if (DrawUtil::isCrazy(edge)) { - Base::Console().Log("GO::addGeomFromCompound - edge: %d is crazy\n",i); + Base::Console().Log("GO::addGeomFromCompound - edge: %d is crazy\n", i); continue; } base = BaseGeom::baseFactory(edge); if (!base) { - Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n",i); + Base::Console().Log("Error - GO::addGeomFromCompound - baseFactory failed for edge: %d\n", i); continue; // throw Base::ValueError("GeometryObject::addGeomFromCompound - baseFactory failed"); } @@ -564,14 +564,14 @@ void GeometryObject::addGeomFromCompound(TopoDS_Shape edgeCompound, edgeClass ca std::vector::iterator itVertex = vertexGeom.begin(); for (; itVertex != vertexGeom.end(); itVertex++) { - if ((*itVertex)->isEqual(*v1,Precision::Confusion())) { + if ((*itVertex)->isEqual(*v1, Precision::Confusion())) { v1Add = false; } - if ((*itVertex)->isEqual(*v2,Precision::Confusion())) { + if ((*itVertex)->isEqual(*v2, Precision::Confusion())) { v2Add = false; } if (circle ) { - if ((*itVertex)->isEqual(*c1,Precision::Confusion())) { + if ((*itVertex)->isEqual(*c1, Precision::Confusion())) { c1Add = false; } } @@ -817,15 +817,15 @@ Base::BoundBox3d GeometryObject::calcBoundingBox() const BRepBndLib::AddOptimal((*it)->occEdge, testBox); } } - - double xMin = 0,xMax = 0,yMin = 0,yMax = 0, zMin = 0, zMax = 0; + + double xMin = 0, xMax = 0, yMin = 0, yMax = 0, zMin = 0, zMax = 0; if (testBox.IsVoid()) { Base::Console().Log("INFO - GO::calcBoundingBox - testBox is void\n"); } else { - testBox.Get(xMin,yMin,zMin,xMax,yMax,zMax); + testBox.Get(xMin, yMin, zMin, xMax, yMax, zMax); } - Base::BoundBox3d bbox(xMin,yMin,zMin,xMax,yMax,zMax); + Base::BoundBox3d bbox(xMin, yMin, zMin, xMax, yMax, zMax); return bbox; } @@ -836,7 +836,7 @@ void GeometryObject::pruneVertexGeom(Base::Vector3d center, double radius) for (auto& v: oldVerts) { Base::Vector3d v3 = v->point(); double length = (v3 - center).Length(); - if (length < Precision::Confusion()) { + if (length < Precision::Confusion()) { continue; } else if (length < radius) { newVerts.push_back(v); @@ -872,23 +872,23 @@ gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin, // Base::Console().Message("GO::getViewAxis() - 1 - use only with getLegacyX\n"); (void) flip; gp_Ax2 viewAxis; - gp_Pnt inputCenter(origin.x,origin.y,origin.z); - Base::Vector3d stdZ(0.0,0.0,1.0); - Base::Vector3d stdOrg(0.0,0.0,0.0); + gp_Pnt inputCenter(origin.x, origin.y, origin.z); + Base::Vector3d stdZ(0.0, 0.0, 1.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); Base::Vector3d cross = direction; if (TechDraw::DrawUtil::checkParallel(direction, stdZ)) { - cross = Base::Vector3d(1.0,0.0,0.0); + cross = Base::Vector3d(1.0, 0.0, 0.0); } else { cross.Normalize(); cross = cross.Cross(stdZ); } - - if (cross.IsEqual(stdOrg,FLT_EPSILON)) { + + if (cross.IsEqual(stdOrg, FLT_EPSILON)) { viewAxis = gp_Ax2(inputCenter, gp_Dir(direction.x, direction.y, direction.z)); return viewAxis; } - + viewAxis = gp_Ax2(inputCenter, gp_Dir(direction.x, direction.y, direction.z), gp_Dir(cross.x, cross.y, cross.z)); @@ -904,7 +904,7 @@ gp_Ax2 TechDraw::getViewAxis(const Base::Vector3d origin, { // Base::Console().Message("GO::getViewAxis() - 2\n"); (void) flip; - gp_Pnt inputCenter(origin.x,origin.y,origin.z); + gp_Pnt inputCenter(origin.x, origin.y, origin.z); gp_Ax2 viewAxis; viewAxis = gp_Ax2(inputCenter, gp_Dir(direction.x, direction.y, direction.z), @@ -920,28 +920,28 @@ gp_Ax2 TechDraw::legacyViewAxis1(const Base::Vector3d origin, { // Base::Console().Message("GO::legacyViewAxis1()\n"); gp_Ax2 viewAxis; - gp_Pnt inputCenter(origin.x,origin.y,origin.z); - Base::Vector3d stdZ(0.0,0.0,1.0); - Base::Vector3d stdOrg(0.0,0.0,0.0); - Base::Vector3d flipDirection(direction.x,-direction.y,direction.z); + gp_Pnt inputCenter(origin.x, origin.y, origin.z); + Base::Vector3d stdZ(0.0, 0.0, 1.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); + Base::Vector3d flipDirection(direction.x, -direction.y, direction.z); if (!flip) { - flipDirection = Base::Vector3d(direction.x,direction.y,direction.z); + flipDirection = Base::Vector3d(direction.x, direction.y, direction.z); } Base::Vector3d cross = flipDirection; // //special case if (TechDraw::DrawUtil::checkParallel(flipDirection, stdZ)) { - cross = Base::Vector3d(1.0,0.0,0.0); + cross = Base::Vector3d(1.0, 0.0, 0.0); } else { cross.Normalize(); cross = cross.Cross(stdZ); } - - if (cross.IsEqual(stdOrg,FLT_EPSILON)) { + + if (cross.IsEqual(stdOrg, FLT_EPSILON)) { viewAxis = gp_Ax2(inputCenter, gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z)); return viewAxis; } - + viewAxis = gp_Ax2(inputCenter, gp_Dir(flipDirection.x, flipDirection.y, flipDirection.z), gp_Dir(cross.x, cross.y, cross.z)); @@ -961,9 +961,9 @@ gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape, const Base::Vector3d &direction) { // Base::Console().Message("GO::findCentroid() - 1\n"); - Base::Vector3d origin(0.0,0.0,0.0); - gp_Ax2 viewAxis = getViewAxis(origin,direction); - return findCentroid(shape,viewAxis); + Base::Vector3d origin(0.0, 0.0, 0.0); + gp_Ax2 viewAxis = getViewAxis(origin, direction); + return findCentroid(shape, viewAxis); } //! Returns the centroid of shape, as viewed according to direction @@ -971,8 +971,8 @@ gp_Pnt TechDraw::findCentroid(const TopoDS_Shape &shape, const gp_Ax2 &viewAxis) { // Base::Console().Message("GO::findCentroid() - 2\n"); -// Base::Vector3d origin(0.0,0.0,0.0); -// gp_Ax2 viewAxis = getViewAxis(origin,direction); +// Base::Vector3d origin(0.0, 0.0, 0.0); +// gp_Ax2 viewAxis = getViewAxis(origin, direction); gp_Trsf tempTransform; tempTransform.SetTransformation(viewAxis); @@ -999,8 +999,8 @@ Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape, const Base::Vector3d &direction) { // Base::Console().Message("GO::findCentroidVec() - 1\n"); - gp_Pnt p = TechDraw::findCentroid(shape,direction); - Base::Vector3d result(p.X(),p.Y(),p.Z()); + gp_Pnt p = TechDraw::findCentroid(shape, direction); + Base::Vector3d result(p.X(), p.Y(), p.Z()); return result; } @@ -1008,8 +1008,8 @@ Base::Vector3d TechDraw::findCentroidVec(const TopoDS_Shape &shape, const gp_Ax2 &cs) { // Base::Console().Message("GO::findCentroidVec() - 2\n"); - gp_Pnt p = TechDraw::findCentroid(shape,cs); - Base::Vector3d result(p.X(),p.Y(),p.Z()); + gp_Pnt p = TechDraw::findCentroid(shape, cs); + Base::Vector3d result(p.X(), p.Y(), p.Z()); return result; } @@ -1071,7 +1071,7 @@ TopoDS_Shape TechDraw::rotateShape(const TopoDS_Shape &input, try { gp_Trsf tempTransform; - tempTransform.SetRotation(rotAxis,rotation); + tempTransform.SetRotation(rotAxis, rotation); BRepBuilderAPI_Transform mkTrf(input, tempTransform); transShape = mkTrf.Shape(); } @@ -1089,7 +1089,7 @@ TopoDS_Shape TechDraw::scaleShape(const TopoDS_Shape &input, TopoDS_Shape transShape; try { gp_Trsf scaleTransform; - scaleTransform.SetScale(gp_Pnt(0,0,0), scale); + scaleTransform.SetScale(gp_Pnt(0, 0,0), scale); BRepBuilderAPI_Transform mkTrf(input, scaleTransform); transShape = mkTrf.Shape(); @@ -1108,7 +1108,7 @@ TopoDS_Shape TechDraw::moveShape(const TopoDS_Shape &input, TopoDS_Shape transShape; try { gp_Trsf xlate; - xlate.SetTranslation(gp_Vec(motion.x,motion.y,motion.z)); + xlate.SetTranslation(gp_Vec(motion.x, motion.y, motion.z)); BRepBuilderAPI_Transform mkTrf(input, xlate); transShape = mkTrf.Shape(); diff --git a/src/Mod/TechDraw/App/GeometryObject.h b/src/Mod/TechDraw/App/GeometryObject.h index 1f24baffe1..c10d124a98 100644 --- a/src/Mod/TechDraw/App/GeometryObject.h +++ b/src/Mod/TechDraw/App/GeometryObject.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TECHDRAW_GEOMETRYOBJECT_H -#define _TECHDRAW_GEOMETRYOBJECT_H +#ifndef TECHDRAW_GEOMETRYOBJECT_H +#define TECHDRAW_GEOMETRYOBJECT_H #include @@ -62,7 +62,7 @@ TopoDS_Shape TechDrawExport mirrorShapeVec(const TopoDS_Shape &input, double scale = 1.0); TopoDS_Shape TechDrawExport mirrorShape(const TopoDS_Shape &input, - const gp_Pnt& inputCenter = gp_Pnt(0.0,0.0,0.0), + const gp_Pnt& inputCenter = gp_Pnt(0.0, 0.0, 0.0), double scale = 1.0); TopoDS_Shape TechDrawExport scaleShape(const TopoDS_Shape &input, @@ -111,7 +111,7 @@ public: const BaseGeomPtrVector & getEdgeGeometry() const { return edgeGeom; } const BaseGeomPtrVector getVisibleFaceEdges(bool smooth, bool seam) const; const std::vector & getFaceGeometry() const { return faceGeom; } - + void setVertexGeometry(std::vector newVerts) {vertexGeom = newVerts; } void setEdgeGeometry(BaseGeomPtrVector newGeoms) {edgeGeom = newGeoms; } diff --git a/src/Mod/TechDraw/App/HatchLine.cpp b/src/Mod/TechDraw/App/HatchLine.cpp index ddc4210da3..21ede75323 100644 --- a/src/Mod/TechDraw/App/HatchLine.cpp +++ b/src/Mod/TechDraw/App/HatchLine.cpp @@ -48,29 +48,29 @@ using namespace TechDraw; double LineSet::getMinX() { - double xMin,yMin,zMin,xMax,yMax,zMax; - m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax); + double xMin, yMin, zMin, xMax, yMax, zMax; + m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax); return xMin; } double LineSet::getMinY() { - double xMin,yMin,zMin,xMax,yMax,zMax; - m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax); + double xMin, yMin, zMin, xMax, yMax, zMax; + m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax); return yMin; } double LineSet::getMaxX() { - double xMin,yMin,zMin,xMax,yMax,zMax; - m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax); + double xMin, yMin, zMin, xMax, yMax, zMax; + m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax); return xMax; } double LineSet::getMaxY() { - double xMin,yMin,zMin,xMax,yMax,zMax; - m_box.Get(xMin,yMin,zMin,xMax,yMax,zMax); + double xMin, yMin, zMin, xMax, yMax, zMax; + m_box.Get(xMin, yMin, zMin, xMax, yMax, zMax); return yMax; } @@ -84,18 +84,18 @@ bool LineSet::isDashed() Base::Vector3d LineSet::calcApparentStart(TechDraw::BaseGeomPtr g) { Base::Vector3d result; - Base::Vector3d start(g->getStartPoint().x,g->getStartPoint().y,0.0); + Base::Vector3d start(g->getStartPoint().x, g->getStartPoint().y, 0.0); double angle = getPATLineSpec().getAngle(); if (angle == 0.0) { //horizontal - result = Base::Vector3d(getMinX(),start.y,0.0); + result = Base::Vector3d(getMinX(), start.y, 0.0); } else if ((angle == 90.0) || (angle == -90.0)) { //vertical - result = Base::Vector3d(start.x,getMinY(),0.0); + result = Base::Vector3d(start.x, getMinY(), 0.0); } else { double slope = getPATLineSpec().getSlope(); double y = getMinY(); double x = ((y - start.y) / slope) + start.x; - result = Base::Vector3d(x,y,0); + result = Base::Vector3d(x, y,0); } return result; } @@ -118,16 +118,16 @@ Base::Vector3d LineSet::getUnitOrtho() { Base::Vector3d result; Base::Vector3d unit = getUnitDir(); - Base::Vector3d X(1.0,0.0,0.0); - Base::Vector3d Y(0.0,1.0,0.0); - if (unit.IsEqual(X,0.000001)) { + Base::Vector3d X(1.0, 0.0, 0.0); + Base::Vector3d Y(0.0, 1.0, 0.0); + if (unit.IsEqual(X, 0.000001)) { result = Y; - } else if (unit.IsEqual(Y,0.000001)) { + } else if (unit.IsEqual(Y, 0.000001)) { result = X; } else { double unitX = unit.x; double unitY = unit.y; - result = Base::Vector3d(unitY,-unitX, 0.0); //perpendicular + result = Base::Vector3d(unitY, -unitX, 0.0); //perpendicular } result.Normalize(); //probably redundant return result; @@ -140,14 +140,14 @@ Base::Vector3d LineSet::findAtomStart() Base::Vector3d origin = getOrigin(); double angle = getAngle(); if (angle == 0.0) { - result = Base::Vector3d(getMinX(),origin.y,0.0); + result = Base::Vector3d(getMinX(), origin.y, 0.0); } else if ( (angle == 90.0) || (angle == -90.0) ) { - result = Base::Vector3d(origin.x,getMinY(),0.0); + result = Base::Vector3d(origin.x, getMinY(), 0.0); } else { double minY = getMinY(); double x = origin.x - (origin.y - minY)/getSlope(); - result = Base::Vector3d(x,minY,0.0); + result = Base::Vector3d(x, minY, 0.0); } return result; } @@ -160,7 +160,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of double angle = getAngle(); double patternLength = scale * getPatternLength(); Base::Vector3d lineOrigin; - double distX,distY; + double distX, distY; int overlayIndex = 0; //interval & offset are not patternscaled @@ -168,7 +168,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of if (angle == 0.0) { //odd case - horizontal line distY = (thisStart.y - atomStart.y); //this is patternscaled overlayIndex = (int) round(distY/(scale * getIntervalY())); //this is +/- - lineOrigin = getOrigin() + distY * Base::Vector3d(0.0,1.0,0.0); //move u/d + lineOrigin = getOrigin() + distY * Base::Vector3d(0.0, 1.0, 0.0); //move u/d } else { distX = (thisStart.x - atomStart.x); //this is patternscaled overlayIndex = (int) round(distX/(scale * getIntervalX())); @@ -197,7 +197,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of double patsEndOrg = lenEndOrg/patternLength; if (lenStartOrg < lenEndOrg) { //origin is before start double c = ceil(patsStartOrg); - if (c <= patsEndOrg) { //c is an integer pattern count in [patsStartOrg,patsEndOrg] + if (c <= patsEndOrg) { //c is an integer pattern count in [patsStartOrg, patsEndOrg] result = lineOrigin + c*patternLength*getUnitDir(); offset = 0.0; } else { @@ -208,7 +208,7 @@ Base::Vector3d LineSet::getPatternStartPoint(TechDraw::BaseGeomPtr g, double &of } } else if (lenStartOrg > lenEndOrg) { //origin is after end double c = ceil(patsEndOrg); - if (c <= patsStartOrg) { //c is an integer pattern count in [patsStartOrg,patsEndOrg] + if (c <= patsStartOrg) { //c is an integer pattern count in [patsStartOrg, patsEndOrg] result = lineOrigin - c*patternLength*getUnitDir(); offset = 0.0; } else { @@ -243,7 +243,7 @@ PATLineSpec::~PATLineSpec() void PATLineSpec::init() { m_angle = 0.0; - m_origin = Base::Vector3d(0.0,0.0,0.0); + m_origin = Base::Vector3d(0.0, 0.0, 0.0); m_interval = 1.0; m_offset = 0.0; } @@ -252,11 +252,11 @@ void PATLineSpec::load(std::string& lineSpec) { std::vector values = split(lineSpec); if (values.size() < 5) { - Base::Console().Message( "PATLineSpec::load(%s) invalid entry in pattern\n",lineSpec.c_str() ); + Base::Console().Message( "PATLineSpec::load(%s) invalid entry in pattern\n", lineSpec.c_str() ); return; } m_angle = values[0]; - m_origin = Base::Vector3d(values[1],values[2],0.0); + m_origin = Base::Vector3d(values[1], values[2], 0.0); m_offset = values[3]; m_interval = values[4]; if (values.size() > 5) { @@ -272,13 +272,13 @@ std::vector PATLineSpec::split(std::string line) std::stringstream lineStream(line); std::string cell; - while(std::getline(lineStream,cell, ',')) + while(std::getline(lineStream, cell, ',')) { try { result.push_back(std::stod(cell)); } catch (const std::invalid_argument& ia) { - Base::Console().Warning("Invalid number in cell: %s (%s) \n",cell.c_str(),ia.what()); + Base::Console().Warning("Invalid number in cell: %s (%s) \n", cell.c_str(), ia.what()); result.push_back(0.0); } } @@ -287,17 +287,17 @@ std::vector PATLineSpec::split(std::string line) void PATLineSpec::dump(const char* title) { - Base::Console().Message( "DUMP: %s\n",title); + Base::Console().Message( "DUMP: %s\n", title); Base::Console().Message( "Angle: %.3f\n", m_angle); - Base::Console().Message( "Origin: %s\n",DrawUtil::formatVector(m_origin).c_str()); - Base::Console().Message( "Offset: %.3f\n",m_offset); - Base::Console().Message( "Interval: %.3f\n",m_interval); + Base::Console().Message( "Origin: %s\n", DrawUtil::formatVector(m_origin).c_str()); + Base::Console().Message( "Offset: %.3f\n", m_offset); + Base::Console().Message( "Interval: %.3f\n", m_interval); // std::stringstream ss; // for (auto& d: m_dashParms) { // ss << d << ", "; // } // ss << "end"; -// Base::Console().Message( "DashSpec: %s\n",ss.str().c_str()); +// Base::Console().Message( "DashSpec: %s\n", ss.str().c_str()); m_dashParms.dump("dashspec"); } @@ -320,7 +320,7 @@ std::vector PATLineSpec::getSpecsForPattern(std::string& parmFile, lineSpecs = loadPatternDef(inFile); } else { //this message can come up when changing PAT file or pattern name - Base::Console().Log( "Could not find pattern: %s\n",parmName.c_str() ); + Base::Console().Log( "Could not find pattern: %s\n", parmName.c_str() ); return result; } @@ -338,8 +338,8 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName bool result = false; while ( inFile.good() ){ std::string line; - std::getline(inFile,line); - std::string nameTag = line.substr(0,1); + std::getline(inFile, line); + std::string nameTag = line.substr(0, 1); std::string patternName; std::size_t commaPos; if ((nameTag == ";") || @@ -349,7 +349,7 @@ bool PATLineSpec::findPatternStart(std::ifstream& inFile, std::string& parmName } else if (nameTag == "*") { commaPos = line.find(',',1); if (commaPos != std::string::npos) { - patternName = line.substr(1,commaPos-1); + patternName = line.substr(1, commaPos-1); } else { patternName = line.substr(1); } @@ -369,8 +369,8 @@ std::vector PATLineSpec::loadPatternDef(std::ifstream& inFile) std::vector result; while ( inFile.good() ){ std::string line; - std::getline(inFile,line); - std::string nameTag = line.substr(0,1); + std::getline(inFile, line); + std::string nameTag = line.substr(0, 1); if ((nameTag == ";") || (nameTag == " ") || (line.empty()) ) { //is cr/lf empty? @@ -397,14 +397,14 @@ std::vector PATLineSpec::getPatternList(std::string& parmFile) while ( inFile.good() ){ std::string line; - std::getline(inFile,line); - std::string nameTag = line.substr(0,1); //dupl code here + std::getline(inFile, line); + std::string nameTag = line.substr(0, 1); //dupl code here std::size_t commaPos; if (nameTag == "*") { //found a pattern commaPos = line.find(',',1); std::string patternName; if (commaPos != std::string::npos) { - patternName = line.substr(1,commaPos-1); + patternName = line.substr(1, commaPos-1); } else { patternName = line.substr(1); } @@ -475,7 +475,7 @@ double DashSpec::length() DashSpec DashSpec::reversed() { std::vector p = get(); - std::reverse(p.begin(),p.end()); + std::reverse(p.begin(), p.end()); DashSpec result(p); return result; } @@ -487,7 +487,7 @@ void DashSpec::dump(const char* title) for (auto& p: m_parms) { ss << p << ", "; } - Base::Console().Message("DUMP - DashSpec - %s\n",ss.str().c_str()); + Base::Console().Message("DUMP - DashSpec - %s\n", ss.str().c_str()); } diff --git a/src/Mod/TechDraw/App/HatchLine.h b/src/Mod/TechDraw/App/HatchLine.h index b8fb3714bd..58f00e8869 100644 --- a/src/Mod/TechDraw/App/HatchLine.h +++ b/src/Mod/TechDraw/App/HatchLine.h @@ -22,8 +22,8 @@ //! HatchLine - Classes related to processing PAT files -#ifndef _TechDraw_HATCHLINE_H_ -#define _TechDraw_HATCHLINE_H_ +#ifndef TechDraw_HATCHLINE_H_ +#define TechDraw_HATCHLINE_H_ #include @@ -53,7 +53,7 @@ class TechDrawExport DashSpec public: DashSpec() {} explicit DashSpec(std::vector p) { m_parms = p; } - ~DashSpec() {} + ~DashSpec() = default; double get(int i) {return m_parms.at(i); } std::vector get() {return m_parms;} @@ -112,7 +112,7 @@ class TechDrawExport LineSet { public: LineSet() {} - ~LineSet() {} + ~LineSet() = default; void setPATLineSpec(const PATLineSpec& s) { m_hatchLine = s; } void setEdges(std::vector e) {m_edges = e;} diff --git a/src/Mod/TechDraw/App/LandmarkDimension.cpp b/src/Mod/TechDraw/App/LandmarkDimension.cpp index 466a1d8150..a97fca434b 100644 --- a/src/Mod/TechDraw/App/LandmarkDimension.cpp +++ b/src/Mod/TechDraw/App/LandmarkDimension.cpp @@ -72,7 +72,7 @@ LandmarkDimension::LandmarkDimension() { static const char *group = "Landmark"; //this leaves a blank entry in position 1. - ADD_PROPERTY_TYPE(ReferenceTags,("") , group, App::Prop_Output,"Tags of Dimension Endpoints"); + ADD_PROPERTY_TYPE(ReferenceTags, ("") , group, App::Prop_Output, "Tags of Dimension Endpoints"); std::vector noTags; ReferenceTags.setValues(noTags); } @@ -132,7 +132,7 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute() std::string tag = dvp->addReferenceVertex(loc2d); reprs.push_back(tag); } - ReferenceTags.setValues(reprs); + ReferenceTags.setValues(reprs); } else { //update dvp referenceverts locations int index = 0; @@ -146,9 +146,9 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute() } m_linearPoints.first = points.front(); m_linearPoints.second = points.back(); - + //m_anglePoints.first = //not implemented yet - + App::DocumentObjectExecReturn* dvdResult = DrawViewDimension::execute(); // dvp->resetReferenceVerts(); @@ -161,7 +161,7 @@ App::DocumentObjectExecReturn *LandmarkDimension::execute() Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawViewPart* dvp) const { - Base::Vector3d stdOrg(0.0,0.0,0.0); + Base::Vector3d stdOrg(0.0, 0.0, 0.0); gp_Ax2 viewAxis = dvp->getProjectionCS(stdOrg); Base::Vector3d alignedPt = pt - dvp->getOriginalCentroid(); gp_Pnt gPt(alignedPt.x, alignedPt.y, alignedPt.z); @@ -169,7 +169,7 @@ Base::Vector3d LandmarkDimension::projectPoint(const Base::Vector3d& pt, DrawVie HLRAlgo_Projector projector( viewAxis ); gp_Pnt2d prjPnt; projector.Project(gPt, prjPnt); - Base::Vector3d result(prjPnt.X(),prjPnt.Y(), 0.0); + Base::Vector3d result(prjPnt.X(), prjPnt.Y(), 0.0); result = DrawUtil::invertY(result); return result; } @@ -207,7 +207,7 @@ bool LandmarkDimension::checkReferences2D() const pointPair LandmarkDimension::getPointsTwoVerts() { -// Base::Console().Message("LD::getPointsTwoVerts() - %s\n",getNameInDocument()); +// Base::Console().Message("LD::getPointsTwoVerts() - %s\n", getNameInDocument()); pointPair result; TechDraw::DrawViewPart* dvp = getViewPart(); @@ -252,7 +252,7 @@ void LandmarkDimension::onDocumentRestored() std::string tag = dvp->addReferenceVertex(loc2d); tags.push_back(tag); } - ReferenceTags.setValues(tags); + ReferenceTags.setValues(tags); m_linearPoints.first = points.front(); m_linearPoints.second = points.back(); @@ -262,7 +262,7 @@ void LandmarkDimension::onDocumentRestored() void LandmarkDimension::unsetupObject() { - + // bool isRemoving = testStatus(App::ObjectStatus::Remove); // Base::Console().Message("LD::unsetupObject - isRemove: %d status: %X\n", // isRemoving, getStatus()); @@ -282,7 +282,7 @@ void LandmarkDimension::unsetupObject() //{ // if (PythonObject.is(Py::_None())) { // // ref counter is set to 1 -// PythonObject = Py::Object(new LandmarkDimensionPy(this),true); +// PythonObject = Py::Object(new LandmarkDimensionPy(this), true); // } // return Py::new_reference_to(PythonObject); //} diff --git a/src/Mod/TechDraw/App/LandmarkDimension.h b/src/Mod/TechDraw/App/LandmarkDimension.h index 36c5d3241a..cf9ad5562d 100644 --- a/src/Mod/TechDraw/App/LandmarkDimension.h +++ b/src/Mod/TechDraw/App/LandmarkDimension.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _TechDraw_LandmarkDimension_h_ -#define _TechDraw_LandmarkDimension_h_ +#ifndef TechDraw_LandmarkDimension_h_ +#define TechDraw_LandmarkDimension_h_ #include @@ -51,7 +51,7 @@ public: ~LandmarkDimension() override; App::PropertyStringList ReferenceTags; //tags of 2d vertices in DVP - + App::DocumentObjectExecReturn *execute() override; short mustExecute() const override; void unsetupObject() override; diff --git a/src/Mod/TechDraw/App/LineGroup.cpp b/src/Mod/TechDraw/App/LineGroup.cpp index 80bf4c79b5..12a581a8da 100644 --- a/src/Mod/TechDraw/App/LineGroup.cpp +++ b/src/Mod/TechDraw/App/LineGroup.cpp @@ -95,12 +95,12 @@ void LineGroup::setWeight(std::string s, double weight) void LineGroup::dump(const char* title) { - Base::Console().Message( "DUMP: %s\n",title); + Base::Console().Message( "DUMP: %s\n", title); Base::Console().Message( "Name: %s\n", m_name.c_str()); Base::Console().Message( "Thin: %.3f\n", m_thin); - Base::Console().Message( "Graphic: %.3f\n",m_graphic); - Base::Console().Message( "Thick: %.3f\n",m_thick); - Base::Console().Message( "Extra: %.3f\n",m_extra); + Base::Console().Message( "Graphic: %.3f\n", m_graphic); + Base::Console().Message( "Thick: %.3f\n", m_thick); + Base::Console().Message( "Extra: %.3f\n", m_extra); } //static support function: split comma separated string of values into vector of numbers @@ -111,7 +111,7 @@ std::vector LineGroup::split(std::string line) std::string cell; bool nameCell = true; - while(std::getline(lineStream,cell, ',')) + while(std::getline(lineStream, cell, ',')) { if (nameCell) { nameCell = false; @@ -121,7 +121,7 @@ std::vector LineGroup::split(std::string line) result.push_back(std::stod(cell)); } catch (const std::invalid_argument& ia) { - Base::Console().Warning("Invalid number in cell: %s (%s) \n",cell.c_str(),ia.what()); + Base::Console().Warning("Invalid number in cell: %s (%s) \n", cell.c_str(), ia.what()); result.push_back(0.0); } } @@ -135,7 +135,7 @@ std::string LineGroup::getRecordFromFile(std::string parmFile, int groupNumber) Base::FileInfo fi(parmFile); Base::ifstream inFile(fi, std::ifstream::in); if(!inFile.is_open()) { - Base::Console().Message( "Cannot open LineGroup file: %s\n",parmFile.c_str()); + Base::Console().Message( "Cannot open LineGroup file: %s\n", parmFile.c_str()); return record; } // parse file to get the groupNumber'th line @@ -172,17 +172,17 @@ LineGroup* LineGroup::lineGroupFactory(int groupNumber) if (values.size() < 4) { Base::Console().Error( "LineGroup::invalid entry in %s\n", lgFileName.c_str() ); } else { - lg->setWeight("Thin",values[0]); - lg->setWeight("Graphic",values[1]); - lg->setWeight("Thick",values[2]); - lg->setWeight("Extra",values[3]); + lg->setWeight("Thin", values[0]); + lg->setWeight("Graphic", values[1]); + lg->setWeight("Thick", values[2]); + lg->setWeight("Extra", values[3]); } return lg; } /** * @brief Returns the default line width given a weight name and group number. - * + * * @param weightName can be "Thick", "Thin", "Graphic" or "Extra" * @param lineGroupNumber if -1 will then use groupNumber in preferences. Default value is -1. * @return the default line width. diff --git a/src/Mod/TechDraw/App/LineGroup.h b/src/Mod/TechDraw/App/LineGroup.h index 688f17488f..660d942840 100644 --- a/src/Mod/TechDraw/App/LineGroup.h +++ b/src/Mod/TechDraw/App/LineGroup.h @@ -22,8 +22,8 @@ //! LineGroup - Classes related to processing LineGroup definition CSV files -#ifndef _TechDraw_LINEGROUP_H_ -#define _TechDraw_LINEGROUP_H_ +#ifndef TechDraw_LINEGROUP_H_ +#define TechDraw_LINEGROUP_H_ #include diff --git a/src/Mod/TechDraw/App/Preferences.cpp b/src/Mod/TechDraw/App/Preferences.cpp index 096f19a6f5..3c13ad009d 100644 --- a/src/Mod/TechDraw/App/Preferences.cpp +++ b/src/Mod/TechDraw/App/Preferences.cpp @@ -135,7 +135,7 @@ double Preferences::vertexScale() -//lightgray #D3D3D3 +//lightgray #D3D3D3 bool Preferences::keepPagesUpToDate() { @@ -190,7 +190,7 @@ QString Preferences::defaultTemplate() GetGroup("Mod/TechDraw/Files"); std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Templates/"; std::string defaultFileName = defaultDir + "A4_LandscapeTD.svg"; - std::string prefFileName = hGrp->GetASCII("TemplateFile",defaultFileName.c_str()); + std::string prefFileName = hGrp->GetASCII("TemplateFile", defaultFileName.c_str()); if (prefFileName.empty()) { prefFileName = defaultFileName; } @@ -229,7 +229,7 @@ std::string Preferences::lineGroupFile() GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files"); std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/LineGroup/"; std::string defaultFileName = defaultDir + "LineGroup.csv"; - std::string lgFileName = hGrp->GetASCII("LineGroupFile",defaultFileName.c_str()); + std::string lgFileName = hGrp->GetASCII("LineGroupFile", defaultFileName.c_str()); if (lgFileName.empty()) { lgFileName = defaultFileName; } @@ -245,7 +245,7 @@ std::string Preferences::formatSpec() { Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); - return hGrp->GetASCII("formatSpec","%.2w"); + return hGrp->GetASCII("formatSpec", "%.2w"); } int Preferences::altDecimals() @@ -271,7 +271,7 @@ std::string Preferences::svgFile() std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Patterns/"; std::string defaultFileName = defaultDir + "simple.svg"; - std::string prefHatchFile = hGrp->GetASCII("FileHatch",defaultFileName.c_str()); + std::string prefHatchFile = hGrp->GetASCII("FileHatch", defaultFileName.c_str()); if (prefHatchFile.empty()) { prefHatchFile = defaultFileName; } diff --git a/src/Mod/TechDraw/App/Preferences.h b/src/Mod/TechDraw/App/Preferences.h index 7eacaec1e9..0f6c89c8a9 100644 --- a/src/Mod/TechDraw/App/Preferences.h +++ b/src/Mod/TechDraw/App/Preferences.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _Preferences_h_ -#define _Preferences_h_ +#ifndef Preferences_h_ +#define Preferences_h_ #include diff --git a/src/Mod/TechDraw/App/ProjectionAlgos.cpp b/src/Mod/TechDraw/App/ProjectionAlgos.cpp index f69f7ceac0..9a46a4178e 100644 --- a/src/Mod/TechDraw/App/ProjectionAlgos.cpp +++ b/src/Mod/TechDraw/App/ProjectionAlgos.cpp @@ -113,7 +113,7 @@ void ProjectionAlgos::execute() Handle( HLRBRep_Algo ) brep_hlr = new HLRBRep_Algo; brep_hlr->Add(Input); - gp_Ax2 transform(gp_Pnt(0,0,0),gp_Dir(Direction.x,Direction.y,Direction.z)); + gp_Ax2 transform(gp_Pnt(0, 0,0), gp_Dir(Direction.x, Direction.y, Direction.z)); HLRAlgo_Projector projector( transform ); brep_hlr->Projector(projector); brep_hlr->Update(); @@ -151,10 +151,10 @@ string ProjectionAlgos::getSVG(ExtractionType type, H_style.insert({"stroke-width", "0.15"}); H_style.insert({"stroke-linecap", "butt"}); H_style.insert({"stroke-linejoin", "miter"}); - H_style.insert({"stroke-dasharray", "0.2,0.1)"}); + H_style.insert({"stroke-dasharray", "0.2, 0.1)"}); H_style.insert({"fill", "none"}); - H_style.insert({"transform", "scale(1,-1)"}); - BRepMesh_IncrementalMesh(H,tolerance); + H_style.insert({"transform", "scale(1, -1)"}); + BRepMesh_IncrementalMesh(H, tolerance); result << " +#include + #include #include #include @@ -43,7 +45,7 @@ class TechDrawExport ProjectionAlgos { public: /// Constructor - ProjectionAlgos(const TopoDS_Shape &Input,const Base::Vector3d &Dir); + ProjectionAlgos(const TopoDS_Shape &Input, const Base::Vector3d &Dir); virtual ~ProjectionAlgos(); void execute(); @@ -53,6 +55,7 @@ public: WithHidden = 1, WithSmooth = 2 }; + using XmlAttributes = std::map; std::string getSVG(ExtractionType type, double tolerance=0.05, diff --git a/src/Mod/TechDraw/App/PropertyCenterLineList.cpp b/src/Mod/TechDraw/App/PropertyCenterLineList.cpp index 90faf9c731..59c071cfb5 100644 --- a/src/Mod/TechDraw/App/PropertyCenterLineList.cpp +++ b/src/Mod/TechDraw/App/PropertyCenterLineList.cpp @@ -27,7 +27,7 @@ # include #endif -/// Here the FreeCAD includes sorted by Base,App,Gui...... +/// Here the FreeCAD includes sorted by Base, App, Gui...... #include #include @@ -139,7 +139,7 @@ void PropertyCenterLineList::Save(Writer &writer) const { writer.Stream() << writer.ind() << "" << endl; writer.incInd(); - for (int i = 0; i < getSize(); i++) { + for (int i = 0; i < getSize(); i++) { writer.Stream() << writer.ind() << "getTypeId().getName() << "\">" << endl; writer.incInd(); @@ -167,7 +167,7 @@ void PropertyCenterLineList::Restore(Base::XMLReader &reader) newG->Restore(reader); if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) { - Base::Console().Error("CenterLine \"%s\" within a PropertyCenterLineList was subject to a partial restore.\n",reader.localName()); + Base::Console().Error("CenterLine \"%s\" within a PropertyCenterLineList was subject to a partial restore.\n", reader.localName()); if(isOrderRelevant()) { // Pushes the best try by the CenterLine class values.push_back(newG); diff --git a/src/Mod/TechDraw/App/PropertyCenterLineList.h b/src/Mod/TechDraw/App/PropertyCenterLineList.h index 12085d6f98..f13ed00efe 100644 --- a/src/Mod/TechDraw/App/PropertyCenterLineList.h +++ b/src/Mod/TechDraw/App/PropertyCenterLineList.h @@ -22,8 +22,8 @@ #ifndef TECHDRAW_PropertyCenterLineList_H #define TECHDRAW_PropertyCenterLineList_H - -#include + +#include #include #include diff --git a/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.cpp b/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.cpp index 121cd069b2..0fc7d28fe8 100644 --- a/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.cpp +++ b/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.cpp @@ -27,7 +27,7 @@ # include #endif -/// Here the FreeCAD includes sorted by Base,App,Gui...... +/// Here the FreeCAD includes sorted by Base, App, Gui...... #include #include @@ -169,7 +169,7 @@ void PropertyCosmeticEdgeList::Restore(Base::XMLReader &reader) newG->Restore(reader); if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) { - Base::Console().Error("CosmeticEdge \"%s\" within a PropertyCosmeticEdgeList was subject to a partial restore.\n",reader.localName()); + Base::Console().Error("CosmeticEdge \"%s\" within a PropertyCosmeticEdgeList was subject to a partial restore.\n", reader.localName()); if(isOrderRelevant()) { // Pushes the best try by the CosmeticEdge class values.push_back(newG); diff --git a/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.h b/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.h index 0f323da2bf..d3c0b8ee6d 100644 --- a/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.h +++ b/src/Mod/TechDraw/App/PropertyCosmeticEdgeList.h @@ -22,8 +22,8 @@ #ifndef TECHDRAW_PropertyCosmeticEdgeList_H #define TECHDRAW_PropertyCosmeticEdgeList_H - -#include + +#include #include #include diff --git a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.cpp b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.cpp index 296e52b037..7096241c99 100644 --- a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.cpp +++ b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.cpp @@ -27,7 +27,7 @@ # include #endif -/// Here the FreeCAD includes sorted by Base,App,Gui...... +/// Here the FreeCAD includes sorted by Base, App, Gui...... #include #include @@ -169,7 +169,7 @@ void PropertyCosmeticVertexList::Restore(Base::XMLReader &reader) newG->Restore(reader); if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) { - Base::Console().Error("CosmeticVertex \"%s\" within a PropertyCosmeticVertexList was subject to a partial restore.\n",reader.localName()); + Base::Console().Error("CosmeticVertex \"%s\" within a PropertyCosmeticVertexList was subject to a partial restore.\n", reader.localName()); if(isOrderRelevant()) { // Pushes the best try by the CosmeticVertex class values.push_back(newG); diff --git a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h index d54f2ddca4..6682761116 100644 --- a/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h +++ b/src/Mod/TechDraw/App/PropertyCosmeticVertexList.h @@ -22,8 +22,8 @@ #ifndef TECHDRAW_PropertyCosmeticVertexList_H #define TECHDRAW_PropertyCosmeticVertexList_H - -#include + +#include #include #include diff --git a/src/Mod/TechDraw/App/PropertyGeomFormatList.cpp b/src/Mod/TechDraw/App/PropertyGeomFormatList.cpp index 0688a20152..c7a58d0d43 100644 --- a/src/Mod/TechDraw/App/PropertyGeomFormatList.cpp +++ b/src/Mod/TechDraw/App/PropertyGeomFormatList.cpp @@ -27,7 +27,7 @@ # include #endif -/// Here the FreeCAD includes sorted by Base,App,Gui...... +/// Here the FreeCAD includes sorted by Base, App, Gui...... #include #include @@ -181,7 +181,7 @@ void PropertyGeomFormatList::Restore(Base::XMLReader &reader) newG->Restore(reader); if(reader.testStatus(Base::XMLReader::ReaderStatus::PartialRestoreInObject)) { - Base::Console().Error("GeomFormat \"%s\" within a PropertyGeomFormatList was subject to a partial restore.\n",reader.localName()); + Base::Console().Error("GeomFormat \"%s\" within a PropertyGeomFormatList was subject to a partial restore.\n", reader.localName()); if(isOrderRelevant()) { // Pushes the best try by the GeomFormat class values.push_back(newG); diff --git a/src/Mod/TechDraw/App/PropertyGeomFormatList.h b/src/Mod/TechDraw/App/PropertyGeomFormatList.h index 3e35a84a0c..1ca3abfb96 100644 --- a/src/Mod/TechDraw/App/PropertyGeomFormatList.h +++ b/src/Mod/TechDraw/App/PropertyGeomFormatList.h @@ -22,8 +22,8 @@ #ifndef TECHDRAW_PropertyGeomFormatList_H #define TECHDRAW_PropertyGeomFormatList_H - -#include + +#include #include #include diff --git a/src/Mod/TechDraw/App/QDomNodeModel.cpp b/src/Mod/TechDraw/App/QDomNodeModel.cpp index 25a704a174..e6add21af7 100644 --- a/src/Mod/TechDraw/App/QDomNodeModel.cpp +++ b/src/Mod/TechDraw/App/QDomNodeModel.cpp @@ -232,8 +232,8 @@ QVector QDomNodeModel::namespaceBindings(const QXmlNodeModelIndex & ni } // Per the XML standard: - // "The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but - // need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to + // "The prefix xml is by definition bound to the namespace name http://www.w3.org/XML/1998/namespace. It MAY, but + // need not, be declared, and MUST NOT be bound to any other namespace name. Other prefixes MUST NOT be bound to // this namespace name, and it MUST NOT be declared as the default namespace." // // If the document does not specifically include this namespace, add it now: diff --git a/src/Mod/TechDraw/App/QDomNodeModel.h b/src/Mod/TechDraw/App/QDomNodeModel.h index c74bcd524c..daaa4c5581 100644 --- a/src/Mod/TechDraw/App/QDomNodeModel.h +++ b/src/Mod/TechDraw/App/QDomNodeModel.h @@ -24,8 +24,8 @@ // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. // * Used under BSD license 2.0 * -#ifndef _QDOMNODEMODEL_H_ -#define _QDOMNODEMODEL_H_ +#ifndef QDOMNODEMODEL_H_ +#define QDOMNODEMODEL_H_ #include @@ -67,4 +67,4 @@ private: bool m_ReadOnly; }; -#endif // _QDOMNODEMODEL_H_ +#endif // QDOMNODEMODEL_H_ diff --git a/src/Mod/TechDraw/App/ShapeExtractor.cpp b/src/Mod/TechDraw/App/ShapeExtractor.cpp index 03b5d97f86..524e45010a 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.cpp +++ b/src/Mod/TechDraw/App/ShapeExtractor.cpp @@ -119,7 +119,7 @@ TopoDS_Shape ShapeExtractor::getShapes(const std::vector l sourceShapes.push_back(shape); } else { std::vector shapeList = getShapesFromObject(l); - sourceShapes.insert(sourceShapes.end(),shapeList.begin(),shapeList.end()); + sourceShapes.insert(sourceShapes.end(), shapeList.begin(), shapeList.end()); } } } @@ -265,7 +265,7 @@ std::vector ShapeExtractor::getShapesFromObject(const App::Documen for (auto& d: objs) { shapes = getShapesFromObject(d); if (!shapes.empty()) { - result.insert(result.end(),shapes.begin(),shapes.end()); + result.insert(result.end(), shapes.begin(), shapes.end()); } } //the next 2 bits are mostly for Arch module objects @@ -277,7 +277,7 @@ std::vector ShapeExtractor::getShapesFromObject(const App::Documen for (auto& d: objs) { shapes = getShapesFromObject(d); if (!shapes.empty()) { - result.insert(result.end(),shapes.begin(),shapes.end()); + result.insert(result.end(), shapes.begin(), shapes.end()); } } } else { diff --git a/src/Mod/TechDraw/App/ShapeExtractor.h b/src/Mod/TechDraw/App/ShapeExtractor.h index 7c8025bc4b..2d30930cb0 100644 --- a/src/Mod/TechDraw/App/ShapeExtractor.h +++ b/src/Mod/TechDraw/App/ShapeExtractor.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _ShapeExtractor_h_ -#define _ShapeExtractor_h_ +#ifndef ShapeExtractor_h_ +#define ShapeExtractor_h_ #include @@ -62,4 +62,4 @@ private: } //namespace TechDraw -#endif // #ifndef _ShapeExtractor_h_ +#endif // #ifndef ShapeExtractor_h_ diff --git a/src/Mod/TechDraw/App/TechDrawExport.cpp b/src/Mod/TechDraw/App/TechDrawExport.cpp index b52b7e40c5..6083ceb823 100644 --- a/src/Mod/TechDraw/App/TechDrawExport.cpp +++ b/src/Mod/TechDraw/App/TechDrawExport.cpp @@ -96,7 +96,7 @@ TopoDS_Edge TechDrawOutput::asCircle(const BRepAdaptor_Curve& c) const try { // approximate the circle center from three positions - BRepLProp_CLProps prop(c,c.FirstParameter(),2,Precision::Confusion()); + BRepLProp_CLProps prop(c, c.FirstParameter(), 2,Precision::Confusion()); curv += prop.Curvature(); prop.CentreOfCurvature(pnt); center.ChangeCoord().Add(pnt.Coord()); @@ -166,7 +166,7 @@ TopoDS_Edge TechDrawOutput::asBSpline(const BRepAdaptor_Curve& c, int maxDegree) Standard_Integer maxSegment = 50; Handle(BRepAdaptor_HCurve) hCurve = new BRepAdaptor_HCurve(c); // approximate the curve using a tolerance - Approx_Curve3d approx(hCurve,tol3D,GeomAbs_C0,maxSegment,maxDegree); + Approx_Curve3d approx(hCurve, tol3D, GeomAbs_C0, maxSegment, maxDegree); if (approx.IsDone() && approx.HasResult()) { // have the result Handle(Geom_BSplineCurve) spline = approx.Curve(); @@ -186,7 +186,7 @@ std::string SVGOutput::exportEdges(const TopoDS_Shape& input) std::stringstream result; TopExp_Explorer edges(input, TopAbs_EDGE); - for (int i = 1 ; edges.More(); edges.Next(),i++) { + for (int i = 1 ; edges.More(); edges.Next(), i++) { const TopoDS_Edge& edge = TopoDS::Edge(edges.Current()); BRepAdaptor_Curve adapt(edge); if (adapt.GetType() == GeomAbs_Circle) { @@ -228,14 +228,14 @@ void SVGOutput::printCircle(const BRepAdaptor_Curve& c, std::ostream& out) gp_Pnt m = c.Value((l+f)/2.0); gp_Pnt e = c.Value(l); - gp_Vec v1(m,s); - gp_Vec v2(m,e); - gp_Vec v3(0,0,1); - double a = v3.DotCross(v1,v2); + gp_Vec v1(m, s); + gp_Vec v2(m, e); + gp_Vec v3(0, 0,1); + double a = v3.DotCross(v1, v2); // a full circle if (fabs(l-f) > 1.0 && s.SquareDistance(e) < 0.001) { - out << ""; } // arc of circle @@ -265,25 +265,25 @@ void SVGOutput::printEllipse(const BRepAdaptor_Curve& c, int id, std::ostream& o // If the minor radius is very small compared to the major radius // the geometry actually degenerates to a line - double ratio = std::min(r1,r2)/std::max(r1,r2); + double ratio = std::min(r1, r2)/std::max(r1, r2); if (ratio < 0.001) { printGeneric(c, id, out); return; } - gp_Vec v1(m,s); - gp_Vec v2(m,e); - gp_Vec v3(0,0,1); - double a = v3.DotCross(v1,v2); - + gp_Vec v1(m, s); + gp_Vec v2(m, e); + gp_Vec v3(0, 0,1); + double a = v3.DotCross(v1, v2); + // a full ellipse // See also https://developer.mozilla.org/en/SVG/Tutorial/Paths gp_Dir xaxis = ellp.XAxis().Direction(); - Standard_Real angle = xaxis.AngleWithRef(gp_Dir(1,0,0),gp_Dir(0,0,-1)); + Standard_Real angle = xaxis.AngleWithRef(gp_Dir(1, 0,0), gp_Dir(0, 0,-1)); angle = Base::toDegrees(angle); if (fabs(l-f) > 1.0 && s.SquareDistance(e) < 0.001) { - out << "" << std::endl; - out << "" << std::endl; + out << "" << std::endl; out << "" << std::endl; } @@ -323,7 +323,7 @@ void SVGOutput::printBezier(const BRepAdaptor_Curve& c, int id, std::ostream& ou gp_Pnt p1 = bezier->Pole(1); - str << p1.X() << "," << p1.Y(); + str << p1.X() << ", " << p1.Y(); if (bezier->Degree() == 3) { if (poles != 4) Standard_Failure::Raise("do it the generic way"); @@ -331,9 +331,9 @@ void SVGOutput::printBezier(const BRepAdaptor_Curve& c, int id, std::ostream& ou gp_Pnt p3 = bezier->Pole(3); gp_Pnt p4 = bezier->Pole(4); str << " C" - << p2.X() << "," << p2.Y() << " " - << p3.X() << "," << p3.Y() << " " - << p4.X() << "," << p4.Y() << " "; + << p2.X() << ", " << p2.Y() << " " + << p3.X() << ", " << p3.Y() << " " + << p4.X() << ", " << p4.Y() << " "; } else if (bezier->Degree() == 2) { if (poles != 3) @@ -341,14 +341,14 @@ void SVGOutput::printBezier(const BRepAdaptor_Curve& c, int id, std::ostream& ou gp_Pnt p2 = bezier->Pole(2); gp_Pnt p3 = bezier->Pole(3); str << " Q" - << p2.X() << "," << p2.Y() << " " - << p3.X() << "," << p3.Y() << " "; + << p2.X() << ", " << p2.Y() << " " + << p3.X() << ", " << p3.Y() << " "; } else if (bezier->Degree() == 1) { if (poles != 2) Standard_Failure::Raise("do it the generic way"); gp_Pnt p2 = bezier->Pole(2); - str << " L" << p2.X() << "," << p2.Y() << " "; + str << " L" << p2.X() << ", " << p2.Y() << " "; } else { Standard_Failure::Raise("do it the generic way"); @@ -371,7 +371,7 @@ void SVGOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o Standard_Integer maxDegree = 3, maxSegment = 100; Handle(BRepAdaptor_HCurve) hCurve = new BRepAdaptor_HCurve(c); // approximate the curve using a tolerance - Approx_Curve3d approx(hCurve,tol3D,GeomAbs_C0,maxSegment,maxDegree); + Approx_Curve3d approx(hCurve, tol3D, GeomAbs_C0, maxSegment, maxDegree); if (approx.IsDone() && approx.HasResult()) { // have the result spline = approx.Curve(); @@ -388,7 +388,7 @@ void SVGOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o Standard_Integer poles = bezier->NbPoles(); if (i == 1) { gp_Pnt p1 = bezier->Pole(1); - str << p1.X() << "," << p1.Y(); + str << p1.X() << ", " << p1.Y(); } if (bezier->Degree() == 3) { if (poles != 4) @@ -397,9 +397,9 @@ void SVGOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o gp_Pnt p3 = bezier->Pole(3); gp_Pnt p4 = bezier->Pole(4); str << " C" - << p2.X() << "," << p2.Y() << " " - << p3.X() << "," << p3.Y() << " " - << p4.X() << "," << p4.Y() << " "; + << p2.X() << ", " << p2.Y() << " " + << p3.X() << ", " << p3.Y() << " " + << p4.X() << ", " << p4.Y() << " "; } else if (bezier->Degree() == 2) { if (poles != 3) @@ -407,14 +407,14 @@ void SVGOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o gp_Pnt p2 = bezier->Pole(2); gp_Pnt p3 = bezier->Pole(3); str << " Q" - << p2.X() << "," << p2.Y() << " " - << p3.X() << "," << p3.Y() << " "; + << p2.X() << ", " << p2.Y() << " " + << p3.X() << ", " << p3.Y() << " "; } else if (bezier->Degree() == 1) { if (poles != 2) Standard_Failure::Raise("do it the generic way"); gp_Pnt p2 = bezier->Pole(2); - str << " L" << p2.X() << "," << p2.Y() << " "; + str << " L" << p2.X() << ", " << p2.Y() << " "; } else { Standard_Failure::Raise("do it the generic way"); @@ -436,9 +436,9 @@ void SVGOutput::printGeneric(const BRepAdaptor_Curve& bac, int id, std::ostream& if (!polygon.IsNull()) { const TColgp_Array1OfPnt& nodes = polygon->Nodes(); char c = 'M'; - out << "" << endl; @@ -450,10 +450,10 @@ void SVGOutput::printGeneric(const BRepAdaptor_Curve& bac, int id, std::ostream& gp_Pnt s = bac.Value(f); gp_Pnt e = bac.Value(l); char c = 'M'; - out << "" << endl; } } @@ -469,7 +469,7 @@ std::string DXFOutput::exportEdges(const TopoDS_Shape& input) std::stringstream result; TopExp_Explorer edges(input, TopAbs_EDGE); - for (int i = 1 ; edges.More(); edges.Next(),i++) { + for (int i = 1 ; edges.More(); edges.Next(), i++) { const TopoDS_Edge& edge = TopoDS::Edge(edges.Current()); BRepAdaptor_Curve adapt(edge); if (adapt.GetType() == GeomAbs_Circle) { @@ -510,14 +510,14 @@ void DXFOutput::printCircle(const BRepAdaptor_Curve& c, std::ostream& out) gp_Pnt m = c.Value((l+f)/2.0); gp_Pnt e = c.Value(l); - gp_Vec v1(m,s); - gp_Vec v2(m,e); - gp_Vec v3(0,0,1); - double a = v3.DotCross(v1,v2); + gp_Vec v1(m, s); + gp_Vec v2(m, e); + gp_Vec v3(0, 0,1); + double a = v3.DotCross(v1, v2); // a full circle if (s.SquareDistance(e) < 0.001) { - //out << ""; out << 0 << endl; out << "CIRCLE" << endl; @@ -596,18 +596,18 @@ void DXFOutput::printEllipse(const BRepAdaptor_Curve& c, int /*id*/, std::ostrea const gp_Pnt& p= ellp.Location(); double r1 = ellp.MajorRadius(); double r2 = ellp.MinorRadius(); - double dp = ellp.Axis().Direction().Dot(gp_Vec(0,0,1)); + double dp = ellp.Axis().Direction().Dot(gp_Vec(0, 0,1)); // a full ellipse /* if (s.SquareDistance(e) < 0.001) { - out << ""; } // arc of ellipse else { // See also https://developer.mozilla.org/en/SVG/Tutorial/Paths gp_Dir xaxis = ellp.XAxis().Direction(); - Standard_Real angle = xaxis.Angle(gp_Dir(1,0,0)); + Standard_Real angle = xaxis.Angle(gp_Dir(1, 0,0)); angle = Base::toDegrees(angle); char las = (l-f > D_PI) ? '1' : '0'; // large-arc-flag char swp = (a < 0) ? '1' : '0'; // sweep-flag, i.e. clockwise (0) or counter-clockwise (1) @@ -617,7 +617,7 @@ void DXFOutput::printEllipse(const BRepAdaptor_Curve& c, int /*id*/, std::ostrea << e.X() << " " << e.Y() << "\" />"; }*/ gp_Dir xaxis = ellp.XAxis().Direction(); - double angle = xaxis.AngleWithRef(gp_Dir(1,0,0),gp_Dir(0,0,-1)); + double angle = xaxis.AngleWithRef(gp_Dir(1, 0,0), gp_Dir(0, 0,-1)); //double rotation = Base::toDegrees(angle); double start_angle = c.FirstParameter(); @@ -663,7 +663,7 @@ void DXFOutput::printEllipse(const BRepAdaptor_Curve& c, int /*id*/, std::ostrea out << end_angle << endl; // End angle } -void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& out) //Not even close yet- DF +void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& out) //Not even close yet- DF { try { std::stringstream str; @@ -672,7 +672,7 @@ void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o Standard_Integer maxDegree = 3, maxSegment = 50; Handle(BRepAdaptor_HCurve) hCurve = new BRepAdaptor_HCurve(c); // approximate the curve using a tolerance - Approx_Curve3d approx(hCurve,tol3D,GeomAbs_C0,maxSegment,maxDegree); + Approx_Curve3d approx(hCurve, tol3D, GeomAbs_C0, maxSegment, maxDegree); if (approx.IsDone() && approx.HasResult()) { // have the result spline = approx.Curve(); @@ -680,9 +680,9 @@ void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o printGeneric(c, id, out); return; } - + //GeomConvert_BSplineCurveToBezierCurve crt(spline); - //GeomConvert_BSplineCurveKnotSplitting crt(spline,0); + //GeomConvert_BSplineCurveKnotSplitting crt(spline, 0); //Standard_Integer arcs = crt.NbArcs(); //Standard_Integer arcs = crt.NbSplits()-1; Standard_Integer m = 0; @@ -693,9 +693,9 @@ void DXFOutput::printBSpline(const BRepAdaptor_Curve& c, int id, std::ostream& o for (int i=1; i<= spline->NbKnots(); i++) m += spline->Multiplicity(i); } - TColStd_Array1OfReal knotsequence(1,m); + TColStd_Array1OfReal knotsequence(1, m); spline->KnotSequence(knotsequence); - TColgp_Array1OfPnt poles(1,spline->NbPoles()); + TColgp_Array1OfPnt poles(1, spline->NbPoles()); spline->Poles(poles); @@ -750,7 +750,7 @@ void DXFOutput::printGeneric(const BRepAdaptor_Curve& c, int /*id*/, std::ostrea out << "0" << endl; out << "LINE" << endl; out << "8" << endl; // Group code for layer name - out << "sheet_layer" << endl; // Layer name + out << "sheet_layer" << endl; // Layer name out << "100" << endl; out << "AcDbEntity" << endl; out << "100" << endl; diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp index 69de80a612..360d42f95f 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGui.cpp @@ -89,7 +89,7 @@ void loadTechDrawResource() QFontDatabase fontDB; int rc = fontDB.addApplicationFont(fontFile); if (rc) { - Base::Console().Log("TechDraw failed to load osifont file: %d from: %s\n",rc,qPrintable(fontFile)); + Base::Console().Log("TechDraw failed to load osifont file: %d from: %s\n", rc, qPrintable(fontFile)); } } diff --git a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp index d5796672cf..53014d0f74 100644 --- a/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp +++ b/src/Mod/TechDraw/Gui/AppTechDrawGuiPy.cpp @@ -62,19 +62,19 @@ class Module : public Py::ExtensionModule public: Module() : Py::ExtensionModule("TechDrawGui") { - add_varargs_method("export",&Module::exporter, + add_varargs_method("export", &Module::exporter, "TechDraw hook for FC Gui exporter." ); - add_varargs_method("exportPageAsPdf",&Module::exportPageAsPdf, - "exportPageAsPdf(DrawPageObject,FilePath) -- print page as Pdf to file." + add_varargs_method("exportPageAsPdf", &Module::exportPageAsPdf, + "exportPageAsPdf(DrawPageObject, FilePath) -- print page as Pdf to file." ); - add_varargs_method("exportPageAsSvg",&Module::exportPageAsSvg, - "exportPageAsSvg(DrawPageObject,FilePath) -- print page as Svg to file." + add_varargs_method("exportPageAsSvg", &Module::exportPageAsSvg, + "exportPageAsSvg(DrawPageObject, FilePath) -- print page as Svg to file." ); - add_varargs_method("copyActiveViewToSvgFile",&Module::copyActiveViewToSvgFile, - "copyActiveViewToSvgFile(DrawPageObject,FilePath) -- copy ActiveView to Svg file." + add_varargs_method("copyActiveViewToSvgFile", &Module::copyActiveViewToSvgFile, + "copyActiveViewToSvgFile(DrawPageObject, FilePath) -- copy ActiveView to Svg file." ); - add_varargs_method("addQGIToView",&Module::addQGIToView, + add_varargs_method("addQGIToView", &Module::addQGIToView, "addQGIToView(View, QGraphicsItem) -- insert graphics item into view's graphic." ); add_varargs_method("addQGObjToView", &Module::addQGObjToView, @@ -124,7 +124,7 @@ private: { PyObject* object; char* Name; - if (!PyArg_ParseTuple(args.ptr(), "Oet",&object,"utf-8",&Name)) + if (!PyArg_ParseTuple(args.ptr(), "Oet", &object, "utf-8", &Name)) throw Py::Exception(); std::string EncodedName = std::string(Name); @@ -166,18 +166,18 @@ private: return Py::None(); } -//!exportPageAsPdf(PageObject,FullPath) +//!exportPageAsPdf(PageObject, FullPath) Py::Object exportPageAsPdf(const Py::Tuple& args) { PyObject *pageObj; char* name; - if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) { - throw Py::TypeError("expected (Page,path"); - } - + if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8", &name)) { + throw Py::TypeError("expected (Page, path"); + } + std::string filePath = std::string(name); PyMem_Free(name); - + try { App::DocumentObject* obj = nullptr; Gui::ViewProvider* vp = nullptr; @@ -212,18 +212,18 @@ private: return Py::None(); } -//!exportPageAsSvg(PageObject,FullPath) +//!exportPageAsSvg(PageObject, FullPath) Py::Object exportPageAsSvg(const Py::Tuple& args) { PyObject *pageObj; char* name; - if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8",&name)) { - throw Py::TypeError("expected (Page,path"); - } - + if (!PyArg_ParseTuple(args.ptr(), "Oet", &pageObj, "utf-8", &name)) { + throw Py::TypeError("expected (Page, path"); + } + std::string filePath = std::string(name); PyMem_Free(name); - + try { App::DocumentObject* obj = nullptr; Gui::ViewProvider* vp = nullptr; @@ -257,7 +257,7 @@ private: return Py::None(); } - + //!copyActiveViewToSvgFile(document, fileSpec) Py::Object copyActiveViewToSvgFile(const Py::Tuple& args) { @@ -271,20 +271,20 @@ private: std::string fileSpec; double outWidth = 138.5; //TODO: change to A4 for release double outHeight = 95.0; //ISO A5 defaults - bool paintBackground = true; + bool paintBackground = true; QColor bgColor = QColor(Qt::white); double lineWidth = 1.0; //1 mm double border = 0.0; //no border int mode = 0; //SoRenderManager::RenderMode(0) - AS_IS if (!PyArg_ParseTuple(args.ptr(), "Oet|ddOOddi", - &docObj, "utf-8",&name, + &docObj, "utf-8", &name, &outWidth, &outHeight, &paintObj, &colorObj, &lineWidth, &border, &mode)) { - throw Py::TypeError("expected (doc, file|,options)"); - } + throw Py::TypeError("expected (doc, file|, options)"); + } fileSpec = std::string(name); PyMem_Free(name); @@ -295,7 +295,7 @@ private: paintBackground = false; } - + try { if (PyObject_TypeCheck(docObj, &(App::DocumentPy::Type))) { appDoc = static_cast(docObj)->getDocumentPtr(); @@ -303,7 +303,7 @@ private: App::Color c = TechDraw::DrawUtil::pyTupleToColor(colorObj); bgColor = c.asValue(); } - result = + result = Grabber3d::copyActiveViewToSvgFile(appDoc, fileSpec, outWidth, outHeight, paintBackground, bgColor, @@ -327,7 +327,7 @@ private: PyObject *qgiPy = nullptr; if (!PyArg_ParseTuple(args.ptr(), "O!O", &(TechDraw::DrawViewPy::Type), &viewPy, &qgiPy)) { throw Py::TypeError("expected (view, item)"); - } + } try { App::DocumentObject* obj = nullptr; diff --git a/src/Mod/TechDraw/Gui/Command.cpp b/src/Mod/TechDraw/Gui/Command.cpp index e4d0e156c9..effd540a80 100644 --- a/src/Mod/TechDraw/Gui/Command.cpp +++ b/src/Mod/TechDraw/Gui/Command.cpp @@ -135,8 +135,8 @@ void CmdTechDrawPageDefault::activated(int iMsg) if (tfi.isReadable()) { Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage','%s')", PageName.c_str()); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate','%s')", TemplateName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage', '%s')", PageName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate', '%s')", TemplateName.c_str()); doCommand(Doc, "App.activeDocument().%s.Template = '%s'", TemplateName.c_str(), templateFileName.toStdString().c_str()); doCommand(Doc, "App.activeDocument().%s.Template = App.activeDocument().%s", PageName.c_str(), TemplateName.c_str()); @@ -208,10 +208,10 @@ void CmdTechDrawPageTemplate::activated(int iMsg) if (tfi.isReadable()) { Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Drawing create page")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage','%s')", PageName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawPage', '%s')", PageName.c_str()); // Create the Template Object to attach to the page - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate','%s')", TemplateName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawSVGTemplate', '%s')", TemplateName.c_str()); //why is "Template" property set twice? -wf // once to set DrawSVGTemplate.Template to OS template file name @@ -357,7 +357,7 @@ void CmdTechDrawView::activated(int iMsg) xShapes.push_back(obj); continue; } - //not a Link and not null. assume to be drawable. Undrawables will be + //not a Link and not null. assume to be drawable. Undrawables will be // skipped later. shapes.push_back(obj); if (partObj) { @@ -386,7 +386,7 @@ void CmdTechDrawView::activated(int iMsg) Gui::WaitCursor wc; openCommand(QT_TRANSLATE_NOOP("Command", "Create view")); std::string FeatName = getUniqueObjectName("View"); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewPart','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewPart', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); App::DocumentObject* docObj = getDocument()->getObject(FeatName.c_str()); @@ -400,11 +400,11 @@ void CmdTechDrawView::activated(int iMsg) std::pair dirs = DrawGuiUtil::getProjDirFromFace(partObj, faceName); projDir = dirs.first; getDocument()->setStatus(App::Document::Status::SkipRecompute, true); - doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)", FeatName.c_str(), projDir.x, projDir.y, projDir.z); //do something clever with dirs.second; // dvp->setXDir(dirs.second); - doCommand(Doc, "App.activeDocument().%s.XDirection = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.XDirection = FreeCAD.Vector(%.3f, %.3f, %.3f)", FeatName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); doCommand(Doc, "App.activeDocument().%s.recompute()", FeatName.c_str()); getDocument()->setStatus(App::Document::Status::SkipRecompute, false); @@ -413,9 +413,9 @@ void CmdTechDrawView::activated(int iMsg) std::pair dirs = DrawGuiUtil::get3DDirAndRot(); projDir = dirs.first; getDocument()->setStatus(App::Document::Status::SkipRecompute, true); - doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)", FeatName.c_str(), projDir.x, projDir.y, projDir.z); - doCommand(Doc, "App.activeDocument().%s.XDirection = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.XDirection = FreeCAD.Vector(%.3f, %.3f, %.3f)", FeatName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); // dvp->setXDir(dirs.second); getDocument()->setStatus(App::Document::Status::SkipRecompute, false); @@ -636,7 +636,7 @@ void CmdTechDrawProjectionGroup::activated(int iMsg) xShapes.push_back(obj); continue; } - //not a Link and not null. assume to be drawable. Undrawables will be + //not a Link and not null. assume to be drawable. Undrawables will be // skipped later. shapes.push_back(obj); if (partObj) { @@ -663,7 +663,7 @@ void CmdTechDrawProjectionGroup::activated(int iMsg) openCommand(QT_TRANSLATE_NOOP("Command", "Create Projection Group")); std::string multiViewName = getUniqueObjectName("ProjGroup"); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawProjGroup','%s')", + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawProjGroup', '%s')", multiViewName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), multiViewName.c_str()); @@ -677,22 +677,22 @@ void CmdTechDrawProjectionGroup::activated(int iMsg) if (!faceName.empty()) { std::pair dirs = DrawGuiUtil::getProjDirFromFace(partObj, faceName); getDocument()->setStatus(App::Document::Status::SkipRecompute, true); - doCommand(Doc, "App.activeDocument().%s.Anchor.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z); - doCommand(Doc, "App.activeDocument().%s.Anchor.RotationVector = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.RotationVector = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); - doCommand(Doc, "App.activeDocument().%s.Anchor.XDirection = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.XDirection = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); getDocument()->setStatus(App::Document::Status::SkipRecompute, false); } else { std::pair dirs = DrawGuiUtil::get3DDirAndRot(); getDocument()->setStatus(App::Document::Status::SkipRecompute, true); - doCommand(Doc, "App.activeDocument().%s.Anchor.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z); - doCommand(Doc, "App.activeDocument().%s.Anchor.RotationVector = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.RotationVector = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); - doCommand(Doc, "App.activeDocument().%s.Anchor.XDirection = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Anchor.XDirection = FreeCAD.Vector(%.3f, %.3f, %.3f)", multiViewName.c_str(), dirs.second.x, dirs.second.y, dirs.second.z); getDocument()->setStatus(App::Document::Status::SkipRecompute, false); } @@ -754,11 +754,11 @@ bool CmdTechDrawProjectionGroup::isActive() // openCommand(QT_TRANSLATE_NOOP("Command", "Create view")); // std::string FeatName = getUniqueObjectName("MultiView"); -// doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewMulti','%s')",FeatName.c_str()); +// doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewMulti', '%s')", FeatName.c_str()); // App::DocumentObject *docObj = getDocument()->getObject(FeatName.c_str()); // auto multiView( static_cast(docObj) ); // multiView->Sources.setValues(shapes); -// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); +// doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); // updateActive(); // commitCommand(); //} @@ -937,7 +937,7 @@ void CmdTechDrawClipGroup::activated(int iMsg) std::string FeatName = getUniqueObjectName("Clip"); openCommand(QT_TRANSLATE_NOOP("Command", "Create Clip")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewClip','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewClip', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); commitCommand(); @@ -1145,10 +1145,10 @@ void CmdTechDrawSymbol::activated(int iMsg) std::string FeatName = getUniqueObjectName("Symbol"); filename = Base::Tools::escapeEncodeFilename(filename); openCommand(QT_TRANSLATE_NOOP("Command", "Create Symbol")); - doCommand(Doc, "f = open(\"%s\",'r')", (const char*)filename.toUtf8()); + doCommand(Doc, "f = open(\"%s\", 'r')", (const char*)filename.toUtf8()); doCommand(Doc, "svg = f.read()"); doCommand(Doc, "f.close()"); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSymbol','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSymbol', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Symbol = svg", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); @@ -1202,12 +1202,12 @@ void CmdTechDrawDraftView::activated(int iMsg) std::string FeatName = getUniqueObjectName("DraftView"); std::string SourceName = (*it)->getNameInDocument(); openCommand(QT_TRANSLATE_NOOP("Command", "Create DraftView")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDraft','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDraft', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", FeatName.c_str(), SourceName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); - doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f,%.3f,%.3f)", + doCommand(Doc, "App.activeDocument().%s.Direction = FreeCAD.Vector(%.3f, %.3f, %.3f)", FeatName.c_str(), dirs.first.x, dirs.first.y, dirs.first.z); updateActive(); commitCommand(); @@ -1272,7 +1272,7 @@ void CmdTechDrawArchView::activated(int iMsg) std::string FeatName = getUniqueObjectName("ArchView"); std::string SourceName = archObject->getNameInDocument(); openCommand(QT_TRANSLATE_NOOP("Command", "Create ArchView")); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewArch','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewArch', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", FeatName.c_str(), SourceName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); @@ -1321,7 +1321,7 @@ void CmdTechDrawSpreadsheetView::activated(int iMsg) openCommand(QT_TRANSLATE_NOOP("Command", "Create spreadsheet view")); std::string FeatName = getUniqueObjectName("Sheet"); - doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSpreadsheet','%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewSpreadsheet', '%s')", FeatName.c_str()); doCommand(Doc, "App.activeDocument().%s.Source = App.activeDocument().%s", FeatName.c_str(), SpreadName.c_str()); doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); @@ -1445,7 +1445,7 @@ void CmdTechDrawExportPageDXF::activated(int iMsg) openCommand(QT_TRANSLATE_NOOP("Command", "Save page to dxf")); doCommand(Doc, "import TechDraw"); fileName = Base::Tools::escapeEncodeFilename(fileName); - doCommand(Doc, "TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")", PageName.c_str(), (const char*)fileName.toUtf8()); + doCommand(Doc, "TechDraw.writeDXFPage(App.activeDocument().%s, u\"%s\")", PageName.c_str(), (const char*)fileName.toUtf8()); commitCommand(); } diff --git a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp index 6a0f42d588..3547242e57 100644 --- a/src/Mod/TechDraw/Gui/CommandAnnotate.cpp +++ b/src/Mod/TechDraw/Gui/CommandAnnotate.cpp @@ -60,7 +60,6 @@ #include #include "DrawGuiUtil.h" -#include "MDIViewPage.h" #include "TaskLeaderLine.h" #include "TaskRichAnno.h" #include "TaskCosVertex.h" @@ -68,10 +67,8 @@ #include "TaskLineDecor.h" #include "TaskWeldingSymbol.h" #include "TaskCosmeticLine.h" -#include "ViewProviderPage.h" #include "ViewProviderViewPart.h" #include "QGIView.h" -#include "QGVPage.h" #include "TaskSurfaceFinishSymbols.h" using namespace TechDrawGui; @@ -89,7 +86,7 @@ void execCenterLine(Gui::Command* cmd); void exec2LineCenterLine(Gui::Command* cmd); void exec2PointCenterLine(Gui::Command* cmd); void execLine2Points(Gui::Command* cmd); -std::vector getSelectedSubElements(Gui::Command* cmd, +std::vector getSelectedSubElements(Gui::Command* cmd, TechDraw::DrawViewPart* &dvp, std::string subType = "Edge"); @@ -248,7 +245,7 @@ void CmdTechDrawCosmeticVertexGroup::activated(int iMsg) execQuadrants(this); break; default: - Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n", iMsg); }; updateActive(); Gui::Selection().clearSelection(); @@ -293,16 +290,16 @@ void CmdTechDrawCosmeticVertexGroup::languageChange() QList a = pcAction->actions(); QAction* arc1 = a[0]; - arc1->setText(QApplication::translate("CmdTechDrawCosmeticVertexGroup","Add Cosmetic Vertex")); - arc1->setToolTip(QApplication::translate("TechDraw_CosmeticVertex","Inserts a Cosmetic Vertex into a View")); + arc1->setText(QApplication::translate("CmdTechDrawCosmeticVertexGroup", "Add Cosmetic Vertex")); + arc1->setToolTip(QApplication::translate("TechDraw_CosmeticVertex", "Inserts a Cosmetic Vertex into a View")); arc1->setStatusTip(arc1->toolTip()); QAction* arc2 = a[1]; - arc2->setText(QApplication::translate("CmdMidpoints","Add Midpoint Vertices")); - arc2->setToolTip(QApplication::translate("TechDraw_Midpoints","Inserts Cosmetic Vertices at Midpoint of selected Edges")); + arc2->setText(QApplication::translate("CmdMidpoints", "Add Midpoint Vertices")); + arc2->setToolTip(QApplication::translate("TechDraw_Midpoints", "Inserts Cosmetic Vertices at Midpoint of selected Edges")); arc2->setStatusTip(arc2->toolTip()); QAction* arc3 = a[2]; - arc3->setText(QApplication::translate("CmdQuadrants","Add Quadrant Vertices")); - arc3->setToolTip(QApplication::translate("TechDraw_Quadrants","Inserts Cosmetic Vertices at Quadrant Points of selected Circles")); + arc3->setText(QApplication::translate("CmdQuadrants", "Add Quadrant Vertices")); + arc3->setToolTip(QApplication::translate("TechDraw_Quadrants", "Inserts Cosmetic Vertices at Quadrant Points of selected Circles")); arc3->setStatusTip(arc3->toolTip()); } @@ -560,8 +557,8 @@ void CmdTechDrawAnnotation::activated(int iMsg) std::string FeatName = getUniqueObjectName("Annotation"); openCommand(QT_TRANSLATE_NOOP("Command", "Create Annotation")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewAnnotation','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewAnnotation', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); commitCommand(); } @@ -612,7 +609,7 @@ void CmdTechDrawCenterLineGroup::activated(int iMsg) exec2PointCenterLine(this); break; default: - Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n",iMsg); + Base::Console().Message("CMD::CVGrp - invalid iMsg: %d\n", iMsg); }; } @@ -655,16 +652,16 @@ void CmdTechDrawCenterLineGroup::languageChange() QList a = pcAction->actions(); QAction* arc1 = a[0]; - arc1->setText(QApplication::translate("CmdTechDrawCenterLineGroup","Add Centerline to Faces")); - arc1->setToolTip(QApplication::translate("TechDraw_FaceCenterLine","Adds a Centerline to Faces")); + arc1->setText(QApplication::translate("CmdTechDrawCenterLineGroup", "Add Centerline to Faces")); + arc1->setToolTip(QApplication::translate("TechDraw_FaceCenterLine", "Adds a Centerline to Faces")); arc1->setStatusTip(arc1->toolTip()); QAction* arc2 = a[1]; - arc2->setText(QApplication::translate("Cmd2LineCenterLine","Add Centerline between 2 Lines")); - arc2->setToolTip(QApplication::translate("TechDraw_2LineCenterLine","Adds a Centerline between 2 Lines")); + arc2->setText(QApplication::translate("Cmd2LineCenterLine", "Add Centerline between 2 Lines")); + arc2->setToolTip(QApplication::translate("TechDraw_2LineCenterLine", "Adds a Centerline between 2 Lines")); arc2->setStatusTip(arc2->toolTip()); QAction* arc3 = a[2]; - arc3->setText(QApplication::translate("Cmd2PointCenterLine","Add Centerline between 2 Points")); - arc3->setToolTip(QApplication::translate("TechDraw_2PointCenterLine","Adds a Centerline between 2 Points")); + arc3->setText(QApplication::translate("Cmd2PointCenterLine", "Add Centerline between 2 Points")); + arc3->setToolTip(QApplication::translate("TechDraw_2PointCenterLine", "Adds a Centerline between 2 Points")); arc3->setStatusTip(arc3->toolTip()); } @@ -756,7 +753,7 @@ void execCenterLine(Gui::Command* cmd) } } - if ( (faceNames.empty()) && + if ( (faceNames.empty()) && (edgeNames.empty()) ) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("You must select Faces or an existing CenterLine.")); @@ -1048,7 +1045,7 @@ void execLine2Points(Gui::Command* cmd) //garbage } } - + if (!baseFeat) { QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong Selection"), QObject::tr("You must select a base View for the line.")); @@ -1207,7 +1204,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg) cl2Delete.push_back(tag); } else { Base::Console().Message( - "CMD::CosmeticEraser - edge: %d is confused - source: %d\n",idx,source); + "CMD::CosmeticEraser - edge: %d is confused - source: %d\n", idx, source); } } } else if (geomType == "Vertex") { @@ -1229,7 +1226,7 @@ void CmdTechDrawCosmeticEraser::activated(int iMsg) if (!cv2Delete.empty()) { objFeat->removeCosmeticVertex(cv2Delete); } - + if (!ce2Delete.empty()) { objFeat->removeCosmeticEdge(ce2Delete); } @@ -1372,7 +1369,7 @@ void CmdTechDrawShowAll::activated(int iMsg) QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Wrong selection"), QObject::tr("No Part Views in this selection")); return; - } + } Gui::ViewProvider* vp = QGIView::getViewProvider(baseFeat); auto partVP = dynamic_cast(vp); @@ -1424,7 +1421,7 @@ void CmdTechDrawWeldSymbol::activated(int iMsg) if (!page) { return; } - + std::vector leaders = getSelection(). getObjectsOfType(TechDraw::DrawLeaderLine::getClassTypeId()); std::vector welds = getSelection(). @@ -1481,13 +1478,13 @@ void CmdTechDrawSurfaceFinishSymbols::activated(int iMsg) std::vector selection = this->getSelection().getSelectionEx(); if (selection.empty()) { - QMessageBox::warning(Gui::getMainWindow(),QObject::tr("SurfaceFinishSymbols"),QObject::tr("Selection is empty")); + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("SurfaceFinishSymbols"), QObject::tr("Selection is empty")); return; } TechDraw::DrawViewPart* objFeat = dynamic_cast (selection[0].getObject()); if(!objFeat) { - QMessageBox::warning(Gui::getMainWindow(),QObject::tr("SurfaceFinishSymbols"),QObject::tr("No object selected")); + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("SurfaceFinishSymbols"), QObject::tr("No object selected")); return; } Gui::Control().showDialog(new TechDrawGui::TaskDlgSurfaceFinishSymbols(objFeat)); @@ -1549,7 +1546,7 @@ std::vector getSelectedSubElements(Gui::Command* cmd, QObject::tr("No Part View in Selection")); return selectedSubs; } - + for (auto& s: subNames) { if (TechDraw::DrawUtil::getGeomTypeFromName(s) == subType) { selectedSubs.push_back(s); diff --git a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp index b0b569948b..ad067b0448 100644 --- a/src/Mod/TechDraw/Gui/CommandCreateDims.cpp +++ b/src/Mod/TechDraw/Gui/CommandCreateDims.cpp @@ -134,7 +134,7 @@ CmdTechDrawDimension::CmdTechDrawDimension() void CmdTechDrawDimension::activated(int iMsg) { Q_UNUSED(iMsg); -// bool result = _checkSelection(this,2); +// bool result = _checkSelection(this, 2); // if (!result) // return; // result = _checkDrawViewPart(this); @@ -214,8 +214,8 @@ void CmdTechDrawDimension::activated(int iMsg) // } // openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); -// doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); -// doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() +// doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); +// doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() // ,dimType.c_str()); // dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -224,7 +224,7 @@ void CmdTechDrawDimension::activated(int iMsg) // } // dim->References2D.setValues(objs, subs); -// doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); +// doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); // commitCommand(); // dim->recomputeFeature(); @@ -261,7 +261,7 @@ CmdTechDrawRadiusDimension::CmdTechDrawRadiusDimension() void CmdTechDrawRadiusDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,1); + bool result = _checkSelection(this, 1); if (!result) return; result = _checkDrawViewPart(this); @@ -328,8 +328,8 @@ void CmdTechDrawRadiusDimension::activated(int iMsg) } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"Radius"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -338,7 +338,7 @@ void CmdTechDrawRadiusDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); @@ -377,7 +377,7 @@ CmdTechDrawDiameterDimension::CmdTechDrawDiameterDimension() void CmdTechDrawDiameterDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,1); + bool result = _checkSelection(this, 1); if (!result) return; result = _checkDrawViewPart(this); @@ -440,8 +440,8 @@ void CmdTechDrawDiameterDimension::activated(int iMsg) subs.push_back(SubNames[0]); openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"Diameter"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -450,7 +450,7 @@ void CmdTechDrawDiameterDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -488,7 +488,7 @@ CmdTechDrawLengthDimension::CmdTechDrawLengthDimension() void CmdTechDrawLengthDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,2); + bool result = _checkSelection(this, 2); if (!result) return; result = _checkDrawViewPart(this); @@ -539,8 +539,8 @@ void CmdTechDrawLengthDimension::activated(int iMsg) } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')", FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'", FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() , "Distance"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); if (!dim) { @@ -548,7 +548,7 @@ void CmdTechDrawLengthDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -593,7 +593,7 @@ CmdTechDrawHorizontalDimension::CmdTechDrawHorizontalDimension() void CmdTechDrawHorizontalDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,2); + bool result = _checkSelection(this, 2); if (!result) return; result = _checkDrawViewPart(this); @@ -644,8 +644,8 @@ void CmdTechDrawHorizontalDimension::activated(int iMsg) } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"DistanceX"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -654,7 +654,7 @@ void CmdTechDrawHorizontalDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -698,7 +698,7 @@ CmdTechDrawVerticalDimension::CmdTechDrawVerticalDimension() void CmdTechDrawVerticalDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,2); + bool result = _checkSelection(this, 2); if (!result) return; result = _checkDrawViewPart(this); @@ -731,7 +731,7 @@ void CmdTechDrawVerticalDimension::activated(int iMsg) (_isValidSingleEdge(this) == isDiagonal) ) { objs.push_back(objFeat); subs.push_back(SubNames[0]); - } else if ( _isValidVertexes(this) || + } else if ( _isValidVertexes(this) || (_isValidEdgeToEdge(this) == isVertical) || (_isValidEdgeToEdge(this) == isHorizontal) || (_isValidEdgeToEdge(this) == isDiagonal) || @@ -749,8 +749,8 @@ void CmdTechDrawVerticalDimension::activated(int iMsg) } openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"DistanceY"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); if (!dim) { @@ -758,7 +758,7 @@ void CmdTechDrawVerticalDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -801,7 +801,7 @@ CmdTechDrawAngleDimension::CmdTechDrawAngleDimension() void CmdTechDrawAngleDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,2); + bool result = _checkSelection(this, 2); if (!result) return; result = _checkDrawViewPart(this); @@ -834,15 +834,15 @@ void CmdTechDrawAngleDimension::activated(int iMsg) QObject::tr("Need two straight edges to make an Angle Dimension")); return; } - + objs.push_back(objFeat); objs.push_back(objFeat); subs.push_back(SubNames[0]); subs.push_back(SubNames[1]); openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"Angle"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -851,7 +851,7 @@ void CmdTechDrawAngleDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -889,7 +889,7 @@ CmdTechDraw3PtAngleDimension::CmdTechDraw3PtAngleDimension() void CmdTechDraw3PtAngleDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,3); + bool result = _checkSelection(this, 3); if (!result) return; result = _checkDrawViewPart(this); @@ -930,8 +930,8 @@ void CmdTechDraw3PtAngleDimension::activated(int iMsg) subs.push_back(SubNames[2]); openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str() + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str() ,"Angle3Pt"); dim = dynamic_cast(getDocument()->getObject(FeatName.c_str())); @@ -940,7 +940,7 @@ void CmdTechDraw3PtAngleDimension::activated(int iMsg) } dim->References2D.setValues(objs, subs); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); commitCommand(); dim->recomputeFeature(); @@ -986,7 +986,7 @@ void CmdTechDrawLinkDimension::activated(int iMsg) return; } - bool result = _checkSelection(this,2); + bool result = _checkSelection(this, 2); if (!result) return; @@ -1021,7 +1021,7 @@ void CmdTechDrawLinkDimension::activated(int iMsg) // dialog to select the Dimension to link - Gui::Control().showDialog(new TaskDlgLinkDim(parts,subs,page)); + Gui::Control().showDialog(new TaskDlgLinkDim(parts, subs, page)); page->getDocument()->recompute(); //still need to recompute in Gui. why? } @@ -1075,7 +1075,7 @@ void CmdTechDrawExtentGroup::activated(int iMsg) execVExtent(this); break; default: - Base::Console().Message("CMD::ExtGrp - invalid iMsg: %d\n",iMsg); + Base::Console().Message("CMD::ExtGrp - invalid iMsg: %d\n", iMsg); }; } @@ -1114,12 +1114,12 @@ void CmdTechDrawExtentGroup::languageChange() QList a = pcAction->actions(); QAction* arc1 = a[0]; - arc1->setText(QApplication::translate("CmdTechDrawExtentGroup","Horizontal Extent")); - arc1->setToolTip(QApplication::translate("TechDraw_HorizontalExtent","Insert Horizontal Extent Dimension")); + arc1->setText(QApplication::translate("CmdTechDrawExtentGroup", "Horizontal Extent")); + arc1->setToolTip(QApplication::translate("TechDraw_HorizontalExtent", "Insert Horizontal Extent Dimension")); arc1->setStatusTip(arc1->toolTip()); QAction* arc2 = a[1]; - arc2->setText(QApplication::translate("CmdTechDrawExtentGroup","Vertical Extent")); - arc2->setToolTip(QApplication::translate("TechDraw_VerticalExtentDimension","Insert Vertical Extent Dimension")); + arc2->setText(QApplication::translate("CmdTechDrawExtentGroup", "Vertical Extent")); + arc2->setToolTip(QApplication::translate("TechDraw_VerticalExtentDimension", "Insert Vertical Extent Dimension")); arc2->setStatusTip(arc2->toolTip()); } @@ -1322,7 +1322,7 @@ CmdTechDrawLandmarkDimension::CmdTechDrawLandmarkDimension() void CmdTechDrawLandmarkDimension::activated(int iMsg) { Q_UNUSED(iMsg); - bool result = _checkSelection(this,3); + bool result = _checkSelection(this, 3); if (!result) return; @@ -1357,16 +1357,16 @@ void CmdTechDrawLandmarkDimension::activated(int iMsg) std::string FeatName = getUniqueObjectName("LandmarkDim"); openCommand(QT_TRANSLATE_NOOP("Command", "Create Dimension")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::LandmarkDimension','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::LandmarkDimension', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); if (objects.size() == 2) { //what about distanceX and distanceY?? - doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str(), "Distance"); + doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str(), "Distance"); refs2d.push_back(dvp); refs2d.push_back(dvp); } // } else if (objects.size() == 3) { //not implemented yet -// doCommand(Doc,"App.activeDocument().%s.Type = '%s'",FeatName.c_str(), "Angle3Pt"); +// doCommand(Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str(), "Angle3Pt"); // refs2d.push_back(dvp); // refs2d.push_back(dvp); // refs2d.push_back(dvp); @@ -1381,7 +1381,7 @@ void CmdTechDrawLandmarkDimension::activated(int iMsg) } dim->References2D.setValues(refs2d, subs); dim->References3D.setValues(objects, subs); - + commitCommand(); dim->recomputeFeature(); @@ -1496,7 +1496,7 @@ int _isValidSingleEdge(Gui::Command* cmd) { int GeoId( TechDraw::DrawUtil::getIndexFromName(SubNames[0]) ); TechDraw::BaseGeomPtr geom = objFeat->getGeomByIndex(GeoId); if (!geom) { - Base::Console().Error("Logic Error: no geometry for GeoId: %d\n",GeoId); + Base::Console().Error("Logic Error: no geometry for GeoId: %d\n", GeoId); return isInvalid; } @@ -1563,7 +1563,7 @@ int _isValidEdgeToEdge(Gui::Command* cmd) { const std::vector SubNames = selection[0].getSubNames(); //there has to be 2 - if(SubNames.size() != 2) { + if(SubNames.size() != 2) { return isInvalid; } @@ -1579,7 +1579,7 @@ int _isValidEdgeToEdge(Gui::Command* cmd) { TechDraw::BaseGeomPtr geom1 = objFeat0->getGeomByIndex(GeoId1); if (!geom0 || !geom1) { // missing gometry - Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",GeoId0,GeoId1); + Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n", GeoId0, GeoId1); return isInvalid; } @@ -1611,13 +1611,13 @@ bool _isValidVertexToEdge(Gui::Command* cmd) { std::vector selection = cmd->getSelection().getSelectionEx(); TechDraw::DrawViewPart* objFeat0 = static_cast(selection[0].getObject()); const std::vector SubNames = selection[0].getSubNames(); - + //there has to be 2 if(SubNames.size() != 2) { return false; } - int eId,vId; + int eId, vId; TechDraw::BaseGeomPtr e; TechDraw::VertexPtr v; if (TechDraw::DrawUtil::getGeomTypeFromName(SubNames[0]) == "Edge" && @@ -1634,7 +1634,7 @@ bool _isValidVertexToEdge(Gui::Command* cmd) { e = objFeat0->getGeomByIndex(eId); v = objFeat0->getProjVertexByIndex(vId); if (!e || !v) { - Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n",eId,vId); + Base::Console().Error("Logic Error: no geometry for GeoId: %d or GeoId: %d\n", eId, vId); return false; } diff --git a/src/Mod/TechDraw/Gui/CommandDecorate.cpp b/src/Mod/TechDraw/Gui/CommandDecorate.cpp index a650df65e8..bd9d229010 100644 --- a/src/Mod/TechDraw/Gui/CommandDecorate.cpp +++ b/src/Mod/TechDraw/Gui/CommandDecorate.cpp @@ -126,7 +126,7 @@ void CmdTechDrawHatch::activated(int iMsg) if (rc == QMessageBox::StandardButton::NoButton) { return; } - + removeOld = true; break; } @@ -151,7 +151,7 @@ void CmdTechDrawHatch::activated(int iMsg) for (auto& r: toRemove) { r.second->removeSub(r.first); if (r.second->empty()) { - doCommand(Doc,"App.activeDocument().removeObject('%s')",r.second->getNameInDocument()); + doCommand(Doc, "App.activeDocument().removeObject('%s')", r.second->getNameInDocument()); } } commitCommand(); @@ -160,7 +160,7 @@ void CmdTechDrawHatch::activated(int iMsg) // dialog to fill in hatch values Gui::Control().showDialog(new TaskDlgHatch(partFeat, subNames)); - //Horrible hack to force Tree update ??still required?? + //Horrible hack to force Tree update ??still required?? //WF: yes. ViewProvider will not claim children without this! double x = partFeat->X.getValue(); partFeat->X.setValue(x); @@ -213,8 +213,8 @@ void CmdTechDrawGeometricHatch::activated(int iMsg) featLabel << FeatName << "FX" << TechDraw::DrawUtil::getIndexFromName(subNames.at(0)); openCommand(QT_TRANSLATE_NOOP("Command", "Create GeomHatch")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawGeomHatch','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.Label = '%s'",FeatName.c_str(),featLabel.str().c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawGeomHatch', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.Label = '%s'", FeatName.c_str(), featLabel.str().c_str()); auto geomhatch( static_cast(getDocument()->getObject(FeatName.c_str())) ); geomhatch->Source.setValue(objFeat, subNames); @@ -283,9 +283,9 @@ void CmdTechDrawImage::activated(int iMsg) std::string FeatName = getUniqueObjectName("Image"); fileName = Base::Tools::escapeEncodeFilename(fileName); openCommand(QT_TRANSLATE_NOOP("Command", "Create Image")); - doCommand(Doc,"App.activeDocument().addObject('TechDraw::DrawViewImage','%s')",FeatName.c_str()); - doCommand(Doc,"App.activeDocument().%s.ImageFile = '%s'",FeatName.c_str(),fileName.toUtf8().constData()); - doCommand(Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)",PageName.c_str(),FeatName.c_str()); + doCommand(Doc, "App.activeDocument().addObject('TechDraw::DrawViewImage', '%s')", FeatName.c_str()); + doCommand(Doc, "App.activeDocument().%s.ImageFile = '%s'", FeatName.c_str(), fileName.toUtf8().constData()); + doCommand(Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", PageName.c_str(), FeatName.c_str()); updateActive(); commitCommand(); } @@ -337,7 +337,7 @@ void CmdTechDrawToggleFrame::activated(int iMsg) bool CmdTechDrawToggleFrame::isActive() { bool havePage = DrawGuiUtil::needPage(this); - bool haveView = DrawGuiUtil::needView(this,false); + bool haveView = DrawGuiUtil::needView(this, false); return (havePage && haveView); } diff --git a/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp index f19479ed9f..589d8e7471 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionDims.cpp @@ -557,7 +557,7 @@ void execPosHorizChainDimension(Gui::Command* cmd) { if (!_checkSelection(cmd, selection, "TechDraw PosHorizChainDimension")) { return; } - + Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Pos Horiz Chain Dim")); std::vector validDimension; validDimension = _getDimensions(selection, "DistanceX"); @@ -2287,7 +2287,7 @@ namespace TechDrawGui { objs.push_back(objFeat); subs.push_back(startVertex); subs.push_back(endVertex); - cmd->doCommand(cmd->Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension','%s')", FeatName.c_str()); + cmd->doCommand(cmd->Doc, "App.activeDocument().addObject('TechDraw::DrawViewDimension', '%s')", FeatName.c_str()); cmd->doCommand(cmd->Doc, "App.activeDocument().%s.Type = '%s'", FeatName.c_str(), dimType.c_str()); dim = dynamic_cast(cmd->getDocument()->getObject(FeatName.c_str())); if (!dim) diff --git a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp index 8828407c3d..cfcd079cd9 100644 --- a/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp +++ b/src/Mod/TechDraw/Gui/CommandExtensionPack.cpp @@ -1888,7 +1888,7 @@ namespace TechDrawGui { QGSPage* scenePage = pageVP->getQGSPage(); featName = scenePage->getDrawPage()->getDocument()->getUniqueObjectName("Balloon"); std::string pageName = scenePage->getDrawPage()->getNameInDocument(); - cmd->doCommand(cmd->Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')", + cmd->doCommand(cmd->Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon', '%s')", featName.c_str()); cmd->doCommand(cmd->Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", pageName.c_str(), featName.c_str()); @@ -1908,7 +1908,7 @@ namespace TechDrawGui { QObject::tr("Selection is empty")); return false; } - + objFeat = dynamic_cast(selection[0].getObject()); if (!objFeat) { QMessageBox::warning(Gui::getMainWindow(), diff --git a/src/Mod/TechDraw/Gui/DlgPageChooser.h b/src/Mod/TechDraw/Gui/DlgPageChooser.h index f3db38a431..591c464531 100644 --- a/src/Mod/TechDraw/Gui/DlgPageChooser.h +++ b/src/Mod/TechDraw/Gui/DlgPageChooser.h @@ -48,7 +48,6 @@ private Q_SLOTS: private: void fillList(std::vector labels, std::vector names); -private: Ui_DlgPageChooser* ui; }; diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp index ccb567efb0..dd9ccd266a 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawAdvancedImp.cpp @@ -45,7 +45,7 @@ DlgPrefsTechDrawAdvancedImp::~DlgPrefsTechDrawAdvancedImp() void DlgPrefsTechDrawAdvancedImp::saveSettings() { - ui->cbDetectFaces->onSave(); + ui->cbDetectFaces->onSave(); ui->cbShowSectionEdges->onSave(); ui->cbDebugSection->onSave(); ui->cbDebugDetail->onSave(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp index afe5ad09d2..1b534b4654 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawDimensionsImp.cpp @@ -59,7 +59,7 @@ DlgPrefsTechDrawDimensionsImp::~DlgPrefsTechDrawDimensionsImp() void DlgPrefsTechDrawDimensionsImp::saveSettings() { - ui->pcbStandardAndStyle->onSave(); + ui->pcbStandardAndStyle->onSave(); ui->cbGlobalDecimals->onSave(); ui->cbShowUnits->onSave(); ui->sbAltDecimals->onSave(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp index 8888fd2355..60d8944809 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawGeneralImp.cpp @@ -100,8 +100,8 @@ void DlgPrefsTechDrawGeneralImp::loadSettings() ui->plsb_LabelSize->onRestore(); ui->cbProjAngle->onRestore(); - ui->cbHiddenLineStyle->onRestore(); - + ui->cbHiddenLineStyle->onRestore(); + ui->pfc_DefTemp->onRestore(); ui->pfc_DefDir->onRestore(); ui->pfc_HatchFile->onRestore(); diff --git a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp index f90cf1649f..fd5a74c0d0 100644 --- a/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp +++ b/src/Mod/TechDraw/Gui/DlgPrefsTechDrawScaleImp.cpp @@ -64,7 +64,7 @@ void DlgPrefsTechDrawScaleImp::saveSettings() ui->pdsbPageScale->onSave(); ui->cbViewScaleType->onSave(); ui->pdsbViewScale->onSave(); - ui->pdsbVertexScale->onSave(); + ui->pdsbVertexScale->onSave(); ui->pdsbCenterScale->onSave(); ui->pdsbTemplateMark->onSave(); ui->pdsbSymbolScale->onSave(); diff --git a/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp b/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp index a7bda9d681..ec7c7179b9 100644 --- a/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp +++ b/src/Mod/TechDraw/Gui/DrawGuiUtil.cpp @@ -347,7 +347,7 @@ std::pair DrawGuiUtil::get3DDirAndRot() viewDir = Base::Vector3d(dvec[0], dvec[1], dvec[2]); viewDir = viewDir * (-1.0); // Inventor dir is opposite TD projection dir - viewUp = Base::Vector3d(upvec[0],upvec[1],upvec[2]); + viewUp = Base::Vector3d(upvec[0], upvec[1], upvec[2]); // Base::Vector3d dirXup = viewDir.Cross(viewUp); Base::Vector3d right = viewUp.Cross(viewDir); diff --git a/src/Mod/TechDraw/Gui/DrawGuiUtil.h b/src/Mod/TechDraw/Gui/DrawGuiUtil.h index 6704d56473..b425a360b2 100644 --- a/src/Mod/TechDraw/Gui/DrawGuiUtil.h +++ b/src/Mod/TechDraw/Gui/DrawGuiUtil.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DrawGuiUtil_h_ -#define _DrawGuiUtil_h_ +#ifndef DrawGuiUtil_h_ +#define DrawGuiUtil_h_ #include @@ -66,8 +66,8 @@ class TechDrawGuiExport DrawGuiUtil { static bool needView(Gui::Command* cmd, bool partOnly = true); static void dumpRectF(const char* text, const QRectF& r); static void dumpPointF(const char* text, const QPointF& p); - static std::pair get3DDirAndRot(); - static std::pair getProjDirFromFace(App::DocumentObject* obj, + static std::pair get3DDirAndRot(); + static std::pair getProjDirFromFace(App::DocumentObject* obj, std::string faceName); static void loadArrowBox(QComboBox* qcb); diff --git a/src/Mod/TechDraw/Gui/Grabber3d.cpp b/src/Mod/TechDraw/Gui/Grabber3d.cpp index f6a0139496..436f4b3e3a 100644 --- a/src/Mod/TechDraw/Gui/Grabber3d.cpp +++ b/src/Mod/TechDraw/Gui/Grabber3d.cpp @@ -58,7 +58,7 @@ using namespace Gui; //notes for selection view //SoSeparator* newSG; - //for obj in objList: + //for obj in objList: // vProv = obj.ViewObject // sg = vProv.getSG(obj); // for child in sg: @@ -66,7 +66,7 @@ using namespace Gui; // //creates Svg file and returns estimate of scale -double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, +double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, std::string fileSpec, double outWidth, double outHeight, bool paintBackground, const QColor& bgColor, @@ -115,7 +115,7 @@ double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, if (sourceCam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { oCam = static_cast(sourceCam); sourceHeight = oCam->height.getValue(); - } else if (sourceCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { + } else if (sourceCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { pCam = static_cast(sourceCam); sourceAngle = pCam->heightAngle.getValue(); } @@ -144,7 +144,7 @@ double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, if (sourceCam->getTypeId() == SoOrthographicCamera::getClassTypeId()) { viewerSvg->setCameraType(SoOrthographicCamera::getClassTypeId()); - } else if (sourceCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { + } else if (sourceCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { viewerSvg->setCameraType(SoPerspectiveCamera::getClassTypeId()); } @@ -164,7 +164,7 @@ double Grabber3d::copyActiveViewToSvgFile(App::Document* appDoc, SoOrthographicCamera* oSvgCam = static_cast(svgCam); double newHeight = sourceHeight * zoomFactor; oSvgCam->height.setValue(newHeight); - } else if (svgCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { + } else if (svgCam->getTypeId() == SoPerspectiveCamera::getClassTypeId()) { SoPerspectiveCamera* vSvgCam = static_cast(svgCam); vSvgCam->heightAngle.setValue(sourceAngle); } @@ -241,7 +241,7 @@ SoSeparator* Grabber3d::copySceneGraph(SoNode* sgIn) //loosely based on View3DInventorViewer::saveGraphic void Grabber3d::execVectorizeAction(Gui::View3DInventorViewer* viewer, SoVectorizeAction* va, - double width, double height, + double width, double height, bool paintBackground, const QColor& bgColor, double lineWidth, double border) { @@ -252,7 +252,7 @@ void Grabber3d::execVectorizeAction(Gui::View3DInventorViewer* viewer, vaFC->setLineWidth(lineWidth); vaFC->setUseMM(true); } - + if (paintBackground && bgColor.isValid()) { va->setBackgroundColor(true, SbColor(bgColor.redF(), bgColor.greenF(), bgColor.blueF())); } else { @@ -282,17 +282,17 @@ double Grabber3d::getViewerScale(Gui::View3DInventorViewer* viewer) // double qtpxmm = 96; // QScreen *screen = QGuiApplication::primaryScreen(); // double qtppi = screen->physicalDotsPerInch(); //~111 dpi -// qtpxmm = qtppi / 25.4; +// qtpxmm = qtppi / 25.4; SbViewportRegion vpRegion = viewer->getSoRenderManager()->getViewportRegion(); SbVec2s winSizePx = vpRegion.getWindowSize(); //pixel coords - Base::Vector3d p1v(0,0,0); + Base::Vector3d p1v(0, 0,0); Base::Vector3d p2v(winSizePx[0] - 1, winSizePx[1] - 1); double screenLengthpx = (p2v - p1v).Length(); //length in pixels double screenLengthmm = (screenLengthpx / coinpxmm); - SbVec2s p1s(0,0); + SbVec2s p1s(0, 0); SbVec2s p2s(winSizePx[0] - 1, winSizePx[1] - 1); SbVec3f p1w = viewer->getPointOnFocalPlane(p1s); SbVec3f p2w = viewer->getPointOnFocalPlane(p2s); @@ -317,12 +317,12 @@ double Grabber3d::getPaperScale(Gui::View3DInventorViewer* viewer, // double qtpxmm = 96; // QScreen *screen = QGuiApplication::primaryScreen(); // double qtppi = screen->physicalDotsPerInch(); //~111 dpi -// qtpxmm = qtppi / 25.4; +// qtpxmm = qtppi / 25.4; SbViewportRegion vpRegion = viewer->getSoRenderManager()->getViewportRegion(); SbVec2s winSizePx = vpRegion.getWindowSize(); //pixel coords - Base::Vector3d p1v(0,0,0); + Base::Vector3d p1v(0, 0,0); Base::Vector3d p2v(winSizePx[0] - 1, winSizePx[1] - 1); double screenLengthpx = (p2v - p1v).Length(); //length in pixels diff --git a/src/Mod/TechDraw/Gui/Grabber3d.h b/src/Mod/TechDraw/Gui/Grabber3d.h index c181edd4ea..fdffa87216 100644 --- a/src/Mod/TechDraw/Gui/Grabber3d.h +++ b/src/Mod/TechDraw/Gui/Grabber3d.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _Grabber3d_h_ -#define _Grabber3d_h_ +#ifndef Grabber3d_h_ +#define Grabber3d_h_ #include @@ -54,11 +54,11 @@ namespace TechDrawGui /// Utility functions for obtaining 3d window image class TechDrawGuiExport Grabber3d { public: - static double copyActiveViewToSvgFile(App::Document* appDoc, + static double copyActiveViewToSvgFile(App::Document* appDoc, std::string fileSpec, double outWidth = 138.5, //TODO: change to A4 for release double outHeight = 95.0, //ISO A5 defaults - bool paintBackground = true, + bool paintBackground = true, const QColor& bgcolor = QColor(Qt::white), double lineWidth = 1.0, //1 mm double border = 0.0, //no border @@ -68,7 +68,7 @@ class TechDrawGuiExport Grabber3d { static void execVectorizeAction(Gui::View3DInventorViewer* viewer, SoVectorizeAction* va, - double width, double height, + double width, double height, bool paintBackground, const QColor& bgcolor, double lineWidth, double border); diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.cpp b/src/Mod/TechDraw/Gui/MDIViewPage.cpp index c66b50411f..af81dcf9dc 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.cpp +++ b/src/Mod/TechDraw/Gui/MDIViewPage.cpp @@ -160,11 +160,11 @@ void MDIViewPage::setDocumentName(const std::string& name) m_documentName = name; } -void MDIViewPage::closeEvent(QCloseEvent* ev) +void MDIViewPage::closeEvent(QCloseEvent* event) { // Base::Console().Message("MDIVP::closeEvent()\n"); - MDIView::closeEvent(ev); - if (!ev->isAccepted()) + MDIView::closeEvent(event); + if (!event->isAccepted()) return; detachSelection(); @@ -222,38 +222,38 @@ bool MDIViewPage::onMsg(const char *pMsg, const char **) bool MDIViewPage::onHasMsg(const char* pMsg) const { - if (strcmp("ViewFit",pMsg) == 0) + if (strcmp("ViewFit", pMsg) == 0) return true; else if(strcmp("Redo", pMsg) == 0 && getAppDocument()->getAvailableRedos() > 0) return true; else if(strcmp("Undo", pMsg) == 0 && getAppDocument()->getAvailableUndos() > 0) return true; - else if (strcmp("Print",pMsg) == 0) + else if (strcmp("Print", pMsg) == 0) return true; - else if (strcmp("Save",pMsg) == 0) + else if (strcmp("Save", pMsg) == 0) return true; - else if (strcmp("SaveAs",pMsg) == 0) + else if (strcmp("SaveAs", pMsg) == 0) return true; - else if (strcmp("PrintPreview",pMsg) == 0) + else if (strcmp("PrintPreview", pMsg) == 0) return true; - else if (strcmp("PrintPdf",pMsg) == 0) + else if (strcmp("PrintPdf", pMsg) == 0) return true; return false; } //called by ViewProvider when Page feature Label changes -void MDIViewPage::setTabText(std::string t) +void MDIViewPage::setTabText(std::string tabText) { - if (!isPassive() && !t.empty()) { + if (!isPassive() && !tabText.empty()) { QString cap = QString::fromLatin1("%1 [*]") - .arg(QString::fromUtf8(t.c_str())); + .arg(QString::fromUtf8(tabText.c_str())); setWindowTitle(cap); } } //**** printing routines -void MDIViewPage::getPaperAttributes(void) +void MDIViewPage::getPaperAttributes() { App::DocumentObject *obj = m_vpPage->getDrawPage()->Template.getValue(); auto pageTemplate( dynamic_cast(obj) ); @@ -293,7 +293,7 @@ void MDIViewPage::printPdf(std::string file) } getPaperAttributes(); - QString filename = QString::fromUtf8(file.data(),file.size()); + QString filename = QString::fromUtf8(file.data(), file.size()); QPrinter printer(QPrinter::HighResolution); printer.setFullPage(true); printer.setOutputFileName(filename); @@ -428,9 +428,9 @@ void MDIViewPage::print(QPrinter* printer) width = Rez::guiX(pageTemplate->Width.getValue()); height = Rez::guiX(pageTemplate->Height.getValue()); } - QRectF sourceRect(0.0,-height,width,height); + QRectF sourceRect(0.0, -height, width, height); - m_scene->render(&p, targetRect,sourceRect); + m_scene->render(&p, targetRect, sourceRect); // Reset m_vpPage->setFrameState(saveState); @@ -498,7 +498,7 @@ void MDIViewPage::saveSVG(std::string file) Base::Console().Warning("MDIViewPage - no file specified\n"); return; } - QString filename = QString::fromUtf8(file.data(),file.size()); + QString filename = QString::fromUtf8(file.data(), file.size()); m_scene->saveSvg(filename); } @@ -523,9 +523,9 @@ void MDIViewPage::saveDXF(std::string fileName) std::string PageName = page->getNameInDocument(); fileName = Base::Tools::escapeEncodeFilename(fileName); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Save page to dxf")); - Gui::Command::doCommand(Gui::Command::Doc,"import TechDraw"); - Gui::Command::doCommand(Gui::Command::Doc,"TechDraw.writeDXFPage(App.activeDocument().%s,u\"%s\")", - PageName.c_str(),(const char*)fileName.c_str()); + Gui::Command::doCommand(Gui::Command::Doc, "import TechDraw"); + Gui::Command::doCommand(Gui::Command::Doc, "TechDraw.writeDXFPage(App.activeDocument().%s, u\"%s\")", + PageName.c_str(), (const char*)fileName.c_str()); Gui::Command::commitCommand(); } @@ -603,9 +603,9 @@ void MDIViewPage::preSelectionChanged(const QPoint &pos) } //flag to prevent selection activity within mdivp -void MDIViewPage::blockSceneSelection(const bool state) +void MDIViewPage::blockSceneSelection(const bool isBlocked) { - isSelectionBlocked = state; + isSelectionBlocked = isBlocked; } @@ -746,7 +746,7 @@ void MDIViewPage::sceneSelectionChanged() QList sceneSel = m_qgSceneSelected; //check if really need to change selection - bool sameSel = compareSelections(treeSel,sceneSel); + bool sameSel = compareSelections(treeSel, sceneSel); if (sameSel) { return; } @@ -858,9 +858,9 @@ void MDIViewPage::setTreeToSceneSelect() } //bool accepted = - static_cast (Gui::Selection().addSelection(dimObj->getDocument()->getName(),dimObj->getNameInDocument())); + static_cast (Gui::Selection().addSelection(dimObj->getDocument()->getName(), dimObj->getNameInDocument())); } - + QGMText *mText = dynamic_cast(*it); if(mText) { QGraphicsItem* textParent = mText->QGraphicsItem::parentItem(); @@ -884,7 +884,7 @@ void MDIViewPage::setTreeToSceneSelect() } //bool accepted = - static_cast (Gui::Selection().addSelection(parentFeat->getDocument()->getName(),parentFeat->getNameInDocument())); + static_cast (Gui::Selection().addSelection(parentFeat->getDocument()->getName(), parentFeat->getNameInDocument())); } } else { @@ -933,7 +933,7 @@ bool MDIViewPage::compareSelections(std::vector treeSel, Q treeNames.push_back(s); } } - std::sort(treeNames.begin(),treeNames.end()); + std::sort(treeNames.begin(), treeNames.end()); treeCount = treeNames.size(); for (auto sn : sceneSel) { @@ -961,7 +961,7 @@ bool MDIViewPage::compareSelections(std::vector treeSel, Q sceneNames.push_back(s); } } - std::sort(sceneNames.begin(),sceneNames.end()); + std::sort(sceneNames.begin(), sceneNames.end()); sceneCount = sceneNames.size(); //different # of DrawView* vs QGIV* @@ -990,15 +990,15 @@ bool MDIViewPage::compareSelections(std::vector treeSel, Q ///////////////////end Selection Routines ////////////////////// -void MDIViewPage::showStatusMsg(const char* s1, const char* s2, const char* s3) const +void MDIViewPage::showStatusMsg(const char* string1, const char* string2, const char* string3) const { QString msg = QString::fromLatin1("%1 %2.%3.%4 ") .arg(tr("Selected:"), - QString::fromUtf8(s1), - QString::fromUtf8(s2), - QString::fromUtf8(s3)); + QString::fromUtf8(string1), + QString::fromUtf8(string2), + QString::fromUtf8(string3)); if (Gui::getMainWindow()) { - Gui::getMainWindow()->showMessage(msg,3000); + Gui::getMainWindow()->showMessage(msg, 3000); } } @@ -1050,14 +1050,14 @@ Py::Object MDIViewPagePy::repr() // a trick is to use MDIViewPy as class member and override getattr() to // join the attributes of both classes. This way all methods of MDIViewPy // appear for SheetViewPy, too. -Py::Object MDIViewPagePy::getattr(const char * attr) +Py::Object MDIViewPagePy::getattr(const char * attrName) { if (!getMDIViewPagePtr()) { std::ostringstream s_out; - s_out << "Cannot access attribute '" << attr << "' of deleted object"; + s_out << "Cannot access attribute '" << attrName << "' of deleted object"; throw Py::RuntimeError(s_out.str()); } - std::string name( attr ); + std::string name( attrName ); if (name == "__dict__" || name == "__class__") { Py::Dict dict_self(BaseType::getattr("__dict__")); Py::Dict dict_base(base.getattr("__dict__")); @@ -1068,11 +1068,11 @@ Py::Object MDIViewPagePy::getattr(const char * attr) } try { - return BaseType::getattr(attr); + return BaseType::getattr(attrName); } catch (Py::AttributeError& e) { e.clear(); - return base.getattr(attr); + return base.getattr(attrName); } } diff --git a/src/Mod/TechDraw/Gui/MDIViewPage.h b/src/Mod/TechDraw/Gui/MDIViewPage.h index ab60699b10..d3cce4a5e4 100644 --- a/src/Mod/TechDraw/Gui/MDIViewPage.h +++ b/src/Mod/TechDraw/Gui/MDIViewPage.h @@ -72,11 +72,11 @@ public: void preSelectionChanged(const QPoint &pos); /// QGraphicsScene selection routines - void selectQGIView(App::DocumentObject *obj, bool state); + void selectQGIView(App::DocumentObject *obj, bool isSelected); void clearSceneSelection(); void blockSceneSelection(bool isBlocked); - bool onMsg(const char* pMsg,const char** ppReturn) override; + bool onMsg(const char* pMsg, const char** ppReturn) override; bool onHasMsg(const char* pMsg) const override; void print() override; @@ -97,7 +97,7 @@ public: ViewProviderPage* getViewProviderPage() {return m_vpPage;} - void setTabText(std::string t); + void setTabText(std::string tabText); static MDIViewPage *getFromScene(const QGSPage *scene); void contextMenuEvent(QContextMenuEvent *event) override; @@ -111,30 +111,28 @@ public Q_SLOTS: void savePDF(); void toggleFrame(); void toggleKeepUpdated(); -// void testAction(void); void sceneSelectionChanged(); protected: - void closeEvent(QCloseEvent*) override; + void closeEvent(QCloseEvent* event) override; + + void showStatusMsg(const char* string1, const char* string2, const char* string3) const; - void showStatusMsg(const char* s1, const char* s2, const char* s3) const; - void onDeleteObject(const App::DocumentObject& obj); - using Connection = boost::signals2::connection; - Connection connectDeletedObject; - - bool compareSelections(std::vector treeSel,QList sceneSel); + bool compareSelections(std::vector treeSel, QList sceneSel); void setTreeToSceneSelect(); void sceneSelectionManager(); private: + using Connection = boost::signals2::connection; + Connection connectDeletedObject; + QAction *m_toggleFrameAction; QAction *m_toggleKeepUpdatedAction; QAction *m_exportSVGAction; QAction *m_exportDXFAction; QAction *m_exportPDFAction; -// QAction* m_testAction; std::string m_objectName; std::string m_documentName; @@ -146,7 +144,7 @@ private: QList m_qgSceneSelected; //items in selection order - void getPaperAttributes(void); + void getPaperAttributes(); QPageLayout::Orientation m_orientation; QPageSize::PageSizeId m_paperSize; double m_pagewidth, m_pageheight; @@ -163,7 +161,7 @@ public: ~MDIViewPagePy() override; Py::Object repr() override; - Py::Object getattr(const char *) override; + Py::Object getattr(const char * attrName) override; Py::Object getPage(const Py::Tuple&); Py::Object cast_to_base(const Py::Tuple&); diff --git a/src/Mod/TechDraw/Gui/PreCompiled.h b/src/Mod/TechDraw/Gui/PreCompiled.h index 321afaec6d..aece8d1213 100644 --- a/src/Mod/TechDraw/Gui/PreCompiled.h +++ b/src/Mod/TechDraw/Gui/PreCompiled.h @@ -76,7 +76,7 @@ // Qt Toolkit -#ifndef __QtAll__ +#ifndef _QtAll__ # include #endif #include diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.cpp b/src/Mod/TechDraw/Gui/PreferencesGui.cpp index 48b281653a..fe8a65a5e2 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.cpp +++ b/src/Mod/TechDraw/Gui/PreferencesGui.cpp @@ -171,7 +171,7 @@ double PreferencesGui::edgeFuzz() Base::Reference hGrp = App::GetApplication().GetUserParameter(). GetGroup("BaseApp")->GetGroup("Preferences")-> GetGroup("Mod/TechDraw/General"); - double result = hGrp->GetFloat("EdgeFuzz",10.0); + double result = hGrp->GetFloat("EdgeFuzz", 10.0); return result; } @@ -190,7 +190,7 @@ QString PreferencesGui::weldingDirectory() std::string defaultDir = App::Application::getResourceDir() + "Mod/TechDraw/Symbols/Welding/AWS/"; Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Files"); - + std::string symbolDir = hGrp->GetASCII("WeldingDir", defaultDir.c_str()); if (symbolDir.empty()) { symbolDir = defaultDir; diff --git a/src/Mod/TechDraw/Gui/PreferencesGui.h b/src/Mod/TechDraw/Gui/PreferencesGui.h index 3da59ca9e7..7ea07d762b 100644 --- a/src/Mod/TechDraw/Gui/PreferencesGui.h +++ b/src/Mod/TechDraw/Gui/PreferencesGui.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _PreferencesGui_h_ -#define _PreferencesGui_h_ +#ifndef PreferencesGui_h_ +#define PreferencesGui_h_ #include diff --git a/src/Mod/TechDraw/Gui/QGCustomBorder.cpp b/src/Mod/TechDraw/Gui/QGCustomBorder.cpp index c9fabd025b..b1977733eb 100644 --- a/src/Mod/TechDraw/Gui/QGCustomBorder.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomBorder.cpp @@ -61,7 +61,7 @@ void QGCustomBorder::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } diff --git a/src/Mod/TechDraw/Gui/QGCustomClip.cpp b/src/Mod/TechDraw/Gui/QGCustomClip.cpp index 06173b0852..09eb64f3b2 100644 --- a/src/Mod/TechDraw/Gui/QGCustomClip.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomClip.cpp @@ -50,7 +50,7 @@ QGCustomClip::QGCustomClip() setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); // setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); //good for debugging - m_rect = QRectF(0.,0.,10.,10.); + m_rect = QRectF(0., 0., 10., 10.); } void QGCustomClip::centerAt(QPointF centerPos) @@ -65,7 +65,7 @@ void QGCustomClip::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } void QGCustomClip::setRect(QRectF r) @@ -76,7 +76,7 @@ void QGCustomClip::setRect(QRectF r) void QGCustomClip::setRect(double x, double y, double w, double h) { - QRectF r(x,y,w,h); + QRectF r(x, y,w, h); setRect(r); } @@ -103,7 +103,7 @@ void QGCustomClip::makeMark(double x, double y) { QGICMark* cmItem = new QGICMark(-1); cmItem->setParentItem(this); - cmItem->setPos(x,y); + cmItem->setPos(x, y); cmItem->setThick(1.0); cmItem->setSize(40.0); cmItem->setZValue(ZVALUE::VERTEX); @@ -111,7 +111,7 @@ void QGCustomClip::makeMark(double x, double y) void QGCustomClip::makeMark(Base::Vector3d v) { - makeMark(v.x,v.y); + makeMark(v.x, v.y); } diff --git a/src/Mod/TechDraw/Gui/QGCustomLabel.cpp b/src/Mod/TechDraw/Gui/QGCustomLabel.cpp index a720213023..4b2a1e9043 100644 --- a/src/Mod/TechDraw/Gui/QGCustomLabel.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomLabel.cpp @@ -65,7 +65,7 @@ void QGCustomLabel::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } void QGCustomLabel::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { diff --git a/src/Mod/TechDraw/Gui/QGCustomRect.cpp b/src/Mod/TechDraw/Gui/QGCustomRect.cpp index 0de4c724cd..759c1f922e 100644 --- a/src/Mod/TechDraw/Gui/QGCustomRect.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomRect.cpp @@ -61,7 +61,7 @@ void QGCustomRect::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } diff --git a/src/Mod/TechDraw/Gui/QGCustomSvg.cpp b/src/Mod/TechDraw/Gui/QGCustomSvg.cpp index 09b3d6b533..8b4dc0df5c 100644 --- a/src/Mod/TechDraw/Gui/QGCustomSvg.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomSvg.cpp @@ -61,7 +61,7 @@ void QGCustomSvg::centerAt(double cX, double cY) double height = box.height(); double newX = (cX - width/2.) * scale(); double newY = (cY - height/2.) * scale(); - setPos(newX,newY); + setPos(newX, newY); } bool QGCustomSvg::load(QByteArray *svgBytes) diff --git a/src/Mod/TechDraw/Gui/QGCustomText.cpp b/src/Mod/TechDraw/Gui/QGCustomText.cpp index 5831a12cb6..6daa708265 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.cpp +++ b/src/Mod/TechDraw/Gui/QGCustomText.cpp @@ -76,12 +76,12 @@ void QGCustomText::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } void QGCustomText::justifyLeftAt(QPointF centerPos, bool vCenter) { - justifyLeftAt(centerPos.x(),centerPos.y(), vCenter); + justifyLeftAt(centerPos.x(), centerPos.y(), vCenter); } void QGCustomText::justifyLeftAt(double cX, double cY, bool vCenter) @@ -92,12 +92,12 @@ void QGCustomText::justifyLeftAt(double cX, double cY, bool vCenter) if (vCenter) { newY = cY - height/2.; } - setPos(cX,newY); + setPos(cX, newY); } void QGCustomText::justifyRightAt(QPointF centerPos, bool vCenter) { - justifyRightAt(centerPos.x(),centerPos.y(), vCenter); + justifyRightAt(centerPos.x(), centerPos.y(), vCenter); } void QGCustomText::justifyRightAt(double cX, double cY, bool vCenter) @@ -110,7 +110,7 @@ void QGCustomText::justifyRightAt(double cX, double cY, bool vCenter) if (vCenter) { newY = cY - height/2.; } - setPos(newX,newY); + setPos(newX, newY); } double QGCustomText::getHeight() @@ -253,7 +253,7 @@ void QGCustomText::makeMark(double x, double y) { QGICMark* cmItem = new QGICMark(-1); cmItem->setParentItem(this); - cmItem->setPos(x,y); + cmItem->setPos(x, y); cmItem->setThick(1.0); cmItem->setSize(40.0); cmItem->setZValue(ZVALUE::VERTEX); @@ -261,6 +261,6 @@ void QGCustomText::makeMark(double x, double y) void QGCustomText::makeMark(Base::Vector3d v) { - makeMark(v.x,v.y); + makeMark(v.x, v.y); } diff --git a/src/Mod/TechDraw/Gui/QGCustomText.h b/src/Mod/TechDraw/Gui/QGCustomText.h index 804d6ead43..bdf3787b7f 100644 --- a/src/Mod/TechDraw/Gui/QGCustomText.h +++ b/src/Mod/TechDraw/Gui/QGCustomText.h @@ -67,7 +67,7 @@ public: virtual double getHeight(void); virtual double getWidth(void); - + virtual QColor getNormalColor(void); virtual QColor getPreColor(void); virtual QColor getSelectColor(void); diff --git a/src/Mod/TechDraw/Gui/QGDisplayArea.cpp b/src/Mod/TechDraw/Gui/QGDisplayArea.cpp index 1882342709..16dd152f3d 100644 --- a/src/Mod/TechDraw/Gui/QGDisplayArea.cpp +++ b/src/Mod/TechDraw/Gui/QGDisplayArea.cpp @@ -62,7 +62,7 @@ void QGDisplayArea::centerAt(double cX, double cY) double height = box.height(); double newX = cX - width/2.; double newY = cY - height/2.; - setPos(newX,newY); + setPos(newX, newY); } void QGDisplayArea::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { diff --git a/src/Mod/TechDraw/Gui/QGEPath.cpp b/src/Mod/TechDraw/Gui/QGEPath.cpp index 0f01188377..7c5cd739ce 100644 --- a/src/Mod/TechDraw/Gui/QGEPath.cpp +++ b/src/Mod/TechDraw/Gui/QGEPath.cpp @@ -96,7 +96,7 @@ void QGMarker::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) void QGMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGMarker::mouseDoubleClickEvent(%d)\n",getProjIndex()); +// Base::Console().Message("QGMarker::mouseDoubleClickEvent(%d)\n", getProjIndex()); if (event->button() == Qt::RightButton) { //we're done Q_EMIT endEdit(); return; @@ -106,21 +106,21 @@ void QGMarker::mouseDoubleClickEvent(QGraphicsSceneMouseEvent * event) void QGMarker::keyPressEvent(QKeyEvent * event) { -// Base::Console().Message("QGMarker::keyPressEvent(%d)\n",getProjIndex()); +// Base::Console().Message("QGMarker::keyPressEvent(%d)\n", getProjIndex()); if (event->key() == Qt::Key_Escape) { Q_EMIT endEdit(); } QGIVertex::keyPressEvent(event); } -void QGMarker::setRadius(float r) +void QGMarker::setRadius(float radius) { //TODO:: implement different marker shapes. circle, square, triangle, ??? //if (m_markerShape == Circle) { ... //setRect(QRectF) for rectangular markers - m_radius = r; + m_radius = radius; QPainterPath p; - p.addRect(-r/2.0, -r/2.0, r, r); + p.addRect(-radius/2.0, -radius/2.0, radius, radius); setPath(p); } @@ -138,7 +138,7 @@ QGEPath::QGEPath(QGILeaderLine* leader) : setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); m_ghost = new QGIPrimPath(); //drawing/editing line m_ghost->setParentItem(this); @@ -151,7 +151,7 @@ QGEPath::QGEPath(QGILeaderLine* leader) : QVariant QGEPath::itemChange(GraphicsItemChange change, const QVariant &value) { -// Base::Console().Message("QGEP::itemChange(%d) - type: %d\n", change,type() - QGraphicsItem::UserType); +// Base::Console().Message("QGEP::itemChange(%d) - type: %d\n", change, type() - QGraphicsItem::UserType); if (change == ItemSelectedHasChanged && scene()) { if(isSelected()) { Q_EMIT selected(true); @@ -339,7 +339,7 @@ std::vector QGEPath::getDeltasFromLeader() //announce points editing is finished void QGEPath::updateParent() { -// Base::Console().Message("QGEPath::updateParent() - inEdit: %d pts: %d\n",inEdit(), m_ghostPoints.size()); +// Base::Console().Message("QGEPath::updateParent() - inEdit: %d pts: %d\n", inEdit(), m_ghostPoints.size()); // dumpGhostPoints("QGEP::updateParent"); QPointF attach = m_ghostPoints.front(); if (!inEdit()) { @@ -397,7 +397,7 @@ void QGEPath::dumpGhostPoints(const char* text) int idb = 0; for (auto& d: m_ghostPoints) { Base::Console().Message("%s - point: %d %s\n", text, - idb,TechDraw::DrawUtil::formatVector(d).c_str()); + idb, TechDraw::DrawUtil::formatVector(d).c_str()); idb++; } } @@ -407,7 +407,7 @@ void QGEPath::dumpMarkerPos(const char* text) int idb = 0; for (auto& m: m_markers) { Base::Console().Message("QGEP - %s - markerPos: %d %s\n", text, - idb,TechDraw::DrawUtil::formatVector(m->pos()).c_str()); + idb, TechDraw::DrawUtil::formatVector(m->pos()).c_str()); idb++; } } diff --git a/src/Mod/TechDraw/Gui/QGEPath.h b/src/Mod/TechDraw/Gui/QGEPath.h index f30c6af384..35ac3081ca 100644 --- a/src/Mod/TechDraw/Gui/QGEPath.h +++ b/src/Mod/TechDraw/Gui/QGEPath.h @@ -38,31 +38,32 @@ namespace TechDrawGui class QGIPrimPath; class QGIVertex; class QGIView; +class QGILeaderLine; class TechDrawGuiExport QGMarker : public QObject, public QGIVertex { Q_OBJECT public: explicit QGMarker(int idx); - virtual ~QGMarker(void) {} + ~QGMarker() = default; enum {Type = QGraphicsItem::UserType + 302}; int type() const override { return Type;} - virtual void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; - virtual void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; - virtual void keyPressEvent(QKeyEvent * event) override; + void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; + void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; + void keyPressEvent(QKeyEvent * event) override; - virtual void setRadius(float r) override; + void setRadius(float radius) override; Q_SIGNALS: void dragging(QPointF pos, int idx); void dragFinished(QPointF pos, int idx); void doubleClick(QPointF pos, int idx); - void endEdit(void); + void endEdit(); protected: - virtual void mousePressEvent(QGraphicsSceneMouseEvent *event) override; + void mousePressEvent(QGraphicsSceneMouseEvent *event) override; private: bool m_dragging; @@ -74,31 +75,32 @@ private: class TechDrawGuiExport QGEPath : public QObject, public QGIPrimPath { Q_OBJECT + public: explicit QGEPath(QGILeaderLine* leader); - virtual ~QGEPath() {} + ~QGEPath() = default; enum {Type = QGraphicsItem::UserType + 301}; int type() const override { return Type;} - virtual QRectF boundingRect() const override; - virtual QPainterPath shape() const override; + QRectF boundingRect() const override; + QPainterPath shape() const override; - void inEdit(bool b) { m_inEdit = b; } - bool inEdit(void) { return m_inEdit; } + void inEdit(bool isInEdit) { m_inEdit = isInEdit; } + bool inEdit() const { return m_inEdit; } void startPathEdit(std::vector pathPoints); void showMarkers(std::vector points); void clearMarkers(); - std::vector getDeltasFromLeader(void); + std::vector getDeltasFromLeader(); - void setScale(double s) { m_scale = s; } - double getScale(void) { return m_scale; } + void setScale(double scale) { m_scale = scale; } + double getScale() const { return m_scale; } - void setPoints(std::vector pts) { m_ghostPoints = pts; } + void setPoints(std::vector& pts) { m_ghostPoints = pts; } void updateParent(); - void drawGhost(void); + void drawGhost(); void dumpGhostPoints(const char* text); void dumpMarkerPos(const char* text); @@ -109,7 +111,7 @@ public Q_SLOTS: void onDragFinished(QPointF pos, int index); void onDragging(QPointF pos, int index); void onDoubleClick(QPointF pos, int markerIndex); - void onEndEdit(void); + void onEndEdit(); Q_SIGNALS: void pointsUpdated(QPointF attach, std::vector deltas); @@ -118,11 +120,12 @@ Q_SIGNALS: void selected(bool state); protected: - virtual QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - virtual void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; - virtual void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; - double getEdgeFuzz(void) const; + QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; + void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; + void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; + double getEdgeFuzz() const; +private: std::vector m_ghostPoints; std::vector m_markers; diff --git a/src/Mod/TechDraw/Gui/QGIArrow.cpp b/src/Mod/TechDraw/Gui/QGIArrow.cpp index d97a3fa39c..1a07efcce0 100644 --- a/src/Mod/TechDraw/Gui/QGIArrow.cpp +++ b/src/Mod/TechDraw/Gui/QGIArrow.cpp @@ -51,7 +51,7 @@ QGIArrow::QGIArrow() : m_size(getPrefArrowSize()), m_style(0), m_dirMode(false), - m_dir(Base::Vector3d(1.0,0.0,0.0)) + m_dir(Base::Vector3d(1.0, 0.0, 0.0)) { setFlipped(false); setFillStyle(Qt::SolidPattern); @@ -69,40 +69,40 @@ void QGIArrow::draw() { QPainterPath path; if (m_style == ArrowType::FILLED_ARROW) { if (m_dirMode) { - path = makeFilledTriangle(getDirection(), m_size,m_size/6.0); + path = makeFilledTriangle(getDirection(), m_size, m_size/6.0); } else { - path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //"arrow l/w sb 3/1" ?? + path = makeFilledTriangle(m_size, m_size/6.0, isFlipped()); //"arrow l/w sb 3/1" ?? } } else if (m_style == ArrowType::OPEN_ARROW) { if (m_dirMode) { - path = makeOpenArrow(getDirection(), m_size,m_size/3.0); //broad arrow? + path = makeOpenArrow(getDirection(), m_size, m_size/3.0); //broad arrow? } else { - path = makeOpenArrow(m_size,m_size/3.0,isFlipped()); + path = makeOpenArrow(m_size, m_size/3.0, isFlipped()); } } else if (m_style == ArrowType::TICK) { if (m_dirMode) { - path = makeHashMark(getDirection(), m_size/2.0,m_size/2.0); //big enough? + path = makeHashMark(getDirection(), m_size/2.0, m_size/2.0); //big enough? } else { - path = makeHashMark(m_size/2.0,m_size/2.0,isFlipped()); //big enough? + path = makeHashMark(m_size/2.0, m_size/2.0, isFlipped()); //big enough? } } else if (m_style == ArrowType::DOT) { - path = makeDot(m_size/2.0,m_size/2.0,isFlipped()); + path = makeDot(m_size/2.0, m_size/2.0, isFlipped()); } else if (m_style == ArrowType::OPEN_CIRCLE) { - path = makeOpenDot(m_size/2.0,m_size/2.0,isFlipped()); + path = makeOpenDot(m_size/2.0, m_size/2.0, isFlipped()); } else if (m_style == ArrowType::FORK) { if (m_dirMode) { - path = makeForkArrow(getDirection(), m_size/2.0,m_size/2.0); //big enough? + path = makeForkArrow(getDirection(), m_size/2.0, m_size/2.0); //big enough? } else { - path = makeForkArrow(m_size/2.0,m_size/2.0,isFlipped()); //big enough? + path = makeForkArrow(m_size/2.0, m_size/2.0, isFlipped()); //big enough? } } else if (m_style == ArrowType::FILLED_TRIANGLE){ if (m_dirMode) { path = makePyramid(getDirection(), m_size); } else { - path = makePyramid(m_size,isFlipped()); + path = makePyramid(m_size, isFlipped()); } }else { - path = makeFilledTriangle(m_size,m_size/6.0,isFlipped()); //sb a question mark or ??? + path = makeFilledTriangle(m_size, m_size/6.0, isFlipped()); //sb a question mark or ??? } setPath(path); } @@ -115,15 +115,15 @@ void QGIArrow::setSize(double s) QPainterPath QGIArrow::makeFilledTriangle(double length, double width, bool flipped) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow if (!flipped) { length *= -1; } QPainterPath path; - path.moveTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(-width))); - path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width))); + path.moveTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(length), Rez::guiX(-width))); + path.lineTo(QPointF(Rez::guiX(length), Rez::guiX(width))); path.closeSubpath(); setFillStyle(Qt::SolidPattern); return path; @@ -131,18 +131,18 @@ QPainterPath QGIArrow::makeFilledTriangle(double length, double width, bool flip QPainterPath QGIArrow::makeFilledTriangle(Base::Vector3d dir, double length, double width) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow // dir is direction arrow points Base::Vector3d negDir = -dir; negDir.Normalize(); - Base::Vector3d perp(-negDir.y,negDir.x, 0.0); + Base::Vector3d perp(-negDir.y, negDir.x, 0.0); Base::Vector3d barb1 = negDir * length + perp * width; Base::Vector3d barb2 = negDir * length - perp * width; - + QPainterPath path; - path.moveTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.moveTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(barb1.x), Rez::guiX(barb1.y))); + path.lineTo(QPointF(Rez::guiX(barb2.x), Rez::guiX(barb2.y))); path.closeSubpath(); setFillStyle(Qt::SolidPattern); return path; @@ -150,32 +150,32 @@ QPainterPath QGIArrow::makeFilledTriangle(Base::Vector3d dir, double length, dou QPainterPath QGIArrow::makeOpenArrow(double length, double width, bool flipped) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow if (!flipped) { length *= -1; } QPainterPath path; - path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(-width))); - path.lineTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width))); + path.moveTo(QPointF(Rez::guiX(length), Rez::guiX(-width))); + path.lineTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(length), Rez::guiX(width))); setFillStyle(Qt::NoBrush); return path; } QPainterPath QGIArrow::makeOpenArrow(Base::Vector3d dir, double length, double width) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow Base::Vector3d negDir = -dir; negDir.Normalize(); - Base::Vector3d perp(-negDir.y,negDir.x, 0.0); + Base::Vector3d perp(-negDir.y, negDir.x, 0.0); Base::Vector3d barb1 = negDir * length + perp * width; Base::Vector3d barb2 = negDir * length - perp * width; - + QPainterPath path; - path.moveTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.moveTo(QPointF(Rez::guiX(barb1.x), Rez::guiX(barb1.y))); + path.lineTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(barb2.x), Rez::guiX(barb2.y))); setFillStyle(Qt::NoBrush); return path; } @@ -184,14 +184,14 @@ QPainterPath QGIArrow::makeOpenArrow(Base::Vector3d dir, double length, double w QPainterPath QGIArrow::makeHashMark(double length, double width, bool flipped) //Arch tick { double adjWidth = 1.0; -//(0,0) is tip of arrow +//(0, 0) is tip of arrow if (!flipped) { length *= -1; adjWidth *= -1; } QPainterPath path; - path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(adjWidth * (-width)))); - path.lineTo(QPointF(Rez::guiX(-length),Rez::guiX(adjWidth * width))); + path.moveTo(QPointF(Rez::guiX(length), Rez::guiX(adjWidth * (-width)))); + path.lineTo(QPointF(Rez::guiX(-length), Rez::guiX(adjWidth * width))); setFillStyle(Qt::NoBrush); return path; } @@ -203,13 +203,13 @@ QPainterPath QGIArrow::makeHashMark(Base::Vector3d dir, double length, double wi Base::Vector3d normDir = dir; negDir.Normalize(); normDir.Normalize(); - Base::Vector3d perp(-negDir.y,negDir.x, 0.0); + Base::Vector3d perp(-negDir.y, negDir.x, 0.0); Base::Vector3d barb1 = negDir * length - perp * (adjWidth * width); Base::Vector3d barb2 = normDir * length + perp * (adjWidth * width); - + QPainterPath path; - path.moveTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.moveTo(QPointF(Rez::guiX(barb1.x), Rez::guiX(barb1.y))); + path.lineTo(QPointF(Rez::guiX(barb2.x), Rez::guiX(barb2.y))); setFillStyle(Qt::NoBrush); return path; } @@ -218,7 +218,7 @@ QPainterPath QGIArrow::makeDot(double length, double width, bool flipped) //cl { Q_UNUSED(flipped); QPainterPath path; - path.moveTo(0.0,0.0); ////(0,0) is Center of dot + path.moveTo(0.0, 0.0); ////(0, 0) is Center of dot path.addEllipse(Rez::guiX(-length/2.0), Rez::guiX(-width/2.0), Rez::guiX(length), Rez::guiX(width)); setFillStyle(Qt::SolidPattern); return path; @@ -228,7 +228,7 @@ QPainterPath QGIArrow::makeOpenDot(double length, double width, bool flipped) { Q_UNUSED(flipped); QPainterPath path; - path.moveTo(0.0,0.0); ////(0,0) is Center of dot + path.moveTo(0.0, 0.0); ////(0, 0) is Center of dot path.addEllipse(Rez::guiX(-length/2.0), Rez::guiX(-width/2.0), Rez::guiX(length), Rez::guiX(width)); setFillStyle(Qt::NoBrush); return path; @@ -236,34 +236,34 @@ QPainterPath QGIArrow::makeOpenDot(double length, double width, bool flipped) QPainterPath QGIArrow::makeForkArrow(double length, double width, bool flipped) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow if (flipped) { length *= -1; } QPainterPath path; - path.moveTo(QPointF(Rez::guiX(length),Rez::guiX(-width))); - path.lineTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(length),Rez::guiX(width))); + path.moveTo(QPointF(Rez::guiX(length), Rez::guiX(-width))); + path.lineTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(length), Rez::guiX(width))); setFillStyle(Qt::NoBrush); return path; } QPainterPath QGIArrow::makeForkArrow(Base::Vector3d dir, double length, double width) { -//(0,0) is tip of arrow +//(0, 0) is tip of arrow Base::Vector3d negDir = -dir; Base::Vector3d normDir = dir; negDir.Normalize(); normDir.Normalize(); - Base::Vector3d perp(-normDir.y,normDir.x, 0.0); + Base::Vector3d perp(-normDir.y, normDir.x, 0.0); Base::Vector3d barb1 = normDir * length + perp * width; Base::Vector3d barb2 = normDir * length - perp * width; - + QPainterPath path; - path.moveTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(0.,0.)); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.moveTo(QPointF(Rez::guiX(barb1.x), Rez::guiX(barb1.y))); + path.lineTo(QPointF(0., 0.)); + path.lineTo(QPointF(Rez::guiX(barb2.x), Rez::guiX(barb2.y))); setFillStyle(Qt::NoBrush); return path; } @@ -273,7 +273,7 @@ QPainterPath QGIArrow::makePyramid(double length, bool flipped) double half_width = length/2.; double top = -length; double base = 0.; - // [(0,-width), (0, width)] is base of arrow + // [(0, -width), (0, width)] is base of arrow if (flipped) { top = 0.; base = -length; @@ -282,8 +282,8 @@ QPainterPath QGIArrow::makePyramid(double length, bool flipped) base = Rez::guiX(base); QPainterPath path; path.moveTo(QPointF(top, 0.)); - path.lineTo(QPointF(base,Rez::guiX(-half_width))); - path.lineTo(QPointF(base,Rez::guiX(half_width))); + path.lineTo(QPointF(base, Rez::guiX(-half_width))); + path.lineTo(QPointF(base, Rez::guiX(half_width))); path.closeSubpath(); setFillStyle(Qt::SolidPattern); return path; @@ -291,20 +291,20 @@ QPainterPath QGIArrow::makePyramid(double length, bool flipped) QPainterPath QGIArrow::makePyramid(Base::Vector3d dir, double length) { - //(0,0) is tip of arrow + //(0, 0) is tip of arrow // dir is direction arrow points Base::Vector3d negDir = -dir; negDir.Normalize(); double width = length / 2.; - Base::Vector3d perp(-negDir.y,negDir.x, 0.0); + Base::Vector3d perp(-negDir.y, negDir.x, 0.0); Base::Vector3d barb1 = perp * width; Base::Vector3d barb2 = perp * -width; Base::Vector3d top = negDir * length; QPainterPath path; - path.moveTo(QPointF(Rez::guiX(top.x),Rez::guiX(top.y))); - path.lineTo(QPointF(Rez::guiX(barb1.x),Rez::guiX(barb1.y))); - path.lineTo(QPointF(Rez::guiX(barb2.x),Rez::guiX(barb2.y))); + path.moveTo(QPointF(Rez::guiX(top.x), Rez::guiX(top.y))); + path.lineTo(QPointF(Rez::guiX(barb1.x), Rez::guiX(barb1.y))); + path.lineTo(QPointF(Rez::guiX(barb2.x), Rez::guiX(barb2.y))); path.closeSubpath(); setFillStyle(Qt::SolidPattern); return path; @@ -326,7 +326,7 @@ double QGIArrow::getOverlapAdjust(int style, double size) // ex for fork and tick, adjustment sb zero. 0.25 is good for filled triangle, 0.1 for open arrow. // open circle sb = radius // NOTE: this may need to be adjusted to account for line thickness too. -// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n",style, size); +// Base::Console().Message("QGIA::getOverlapAdjust(%d, %.3f) \n", style, size); double result = 1.0; switch(style) { case FILLED_ARROW: diff --git a/src/Mod/TechDraw/Gui/QGIArrow.h b/src/Mod/TechDraw/Gui/QGIArrow.h index 5417469d03..215dfecf6c 100644 --- a/src/Mod/TechDraw/Gui/QGIArrow.h +++ b/src/Mod/TechDraw/Gui/QGIArrow.h @@ -38,13 +38,13 @@ namespace TechDrawGui { /*enum ArrowType {*/ -/* FILLED_TRIANGLE = 0,*/ -/* OPEN_ARROW,*/ -/* HASH_MARK,*/ -/* DOT,*/ -/* OPEN_CIRCLE,*/ -/* FORK,*/ -/* PYRAMID,*/ +/* FILLED_TRIANGLE = 0, */ +/* OPEN_ARROW, */ +/* HASH_MARK, */ +/* DOT, */ +/* OPEN_CIRCLE, */ +/* FORK, */ +/* PYRAMID, */ /* NONE*/ /*};*/ @@ -80,10 +80,10 @@ protected: QPainterPath makeFilledTriangle(Base::Vector3d dir, double length, double width); QPainterPath makeOpenArrow(double length, double width, bool flipped); QPainterPath makeOpenArrow(Base::Vector3d dir, double length, double width); - QPainterPath makeHashMark(double length, double width, bool flipped); - QPainterPath makeHashMark(Base::Vector3d dir, double length, double width); - QPainterPath makeDot(double length, double width, bool flipped); - QPainterPath makeOpenDot(double length, double width, bool flipped); + QPainterPath makeHashMark(double length, double width, bool flipped); + QPainterPath makeHashMark(Base::Vector3d dir, double length, double width); + QPainterPath makeDot(double length, double width, bool flipped); + QPainterPath makeOpenDot(double length, double width, bool flipped); QPainterPath makeForkArrow(double length, double width, bool flipped); QPainterPath makeForkArrow(Base::Vector3d dir, double length, double width); QPainterPath makePyramid(double length, bool flipped); diff --git a/src/Mod/TechDraw/Gui/QGICMark.cpp b/src/Mod/TechDraw/Gui/QGICMark.cpp index bf560fb50b..efd495d8f3 100644 --- a/src/Mod/TechDraw/Gui/QGICMark.cpp +++ b/src/Mod/TechDraw/Gui/QGICMark.cpp @@ -49,10 +49,10 @@ QGICMark::QGICMark(int index) : QGIVertex(index) void QGICMark::draw() { QPainterPath cmPath; - cmPath.moveTo(0.0,m_size); - cmPath.lineTo(0.0,-m_size); - cmPath.moveTo(m_size,0.0); - cmPath.lineTo(-m_size,0.0); + cmPath.moveTo(0.0, m_size); + cmPath.lineTo(0.0, -m_size); + cmPath.moveTo(m_size, 0.0); + cmPath.lineTo(-m_size, 0.0); setPath(cmPath); } @@ -107,7 +107,7 @@ QPainterPath QGICMark::shape() const { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - double result = hGrp->GetFloat("MarkFuzz",5.0); + double result = hGrp->GetFloat("MarkFuzz", 5.0); return result; } diff --git a/src/Mod/TechDraw/Gui/QGICenterLine.cpp b/src/Mod/TechDraw/Gui/QGICenterLine.cpp index e19986a26d..e37701eb65 100644 --- a/src/Mod/TechDraw/Gui/QGICenterLine.cpp +++ b/src/Mod/TechDraw/Gui/QGICenterLine.cpp @@ -65,10 +65,10 @@ void QGICenterLine::makeLine() } -void QGICenterLine::setBounds(double x1,double y1,double x2,double y2) +void QGICenterLine::setBounds(double x1, double y1, double x2, double y2) { - m_start = QPointF(x1,y1); - m_end = QPointF(x2,y2); + m_start = QPointF(x1, y1); + m_end = QPointF(x2, y2); } QColor QGICenterLine::getCenterColor() diff --git a/src/Mod/TechDraw/Gui/QGICenterLine.h b/src/Mod/TechDraw/Gui/QGICenterLine.h index 052cef956a..fbdc8678eb 100644 --- a/src/Mod/TechDraw/Gui/QGICenterLine.h +++ b/src/Mod/TechDraw/Gui/QGICenterLine.h @@ -44,7 +44,7 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ); - void setBounds(double x1,double y1,double x2,double y2); + void setBounds(double x1, double y1, double x2, double y2); virtual void draw(); void setIntersection(bool isIntersecting); diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.cpp b/src/Mod/TechDraw/Gui/QGIDecoration.cpp index 7c7c2156ac..f15f725ca1 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.cpp +++ b/src/Mod/TechDraw/Gui/QGIDecoration.cpp @@ -55,7 +55,7 @@ QGIDecoration::QGIDecoration() : setAcceptHoverEvents(false); setFlag(QGraphicsItem::ItemIsSelectable, false); setFlag(QGraphicsItem::ItemIsMovable, false); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setWidth(1.0); } @@ -116,7 +116,7 @@ void QGIDecoration::makeMark(double x, double y) { QGICMark* cmItem = new QGICMark(-1); cmItem->setParentItem(this); - cmItem->setPos(x,y); + cmItem->setPos(x, y); cmItem->setThick(2.0); cmItem->setSize(40.0); cmItem->setZValue(ZVALUE::VERTEX); @@ -124,7 +124,7 @@ void QGIDecoration::makeMark(double x, double y) void QGIDecoration::makeMark(Base::Vector3d v) { - makeMark(v.x,v.y); + makeMark(v.x, v.y); } diff --git a/src/Mod/TechDraw/Gui/QGIEdge.cpp b/src/Mod/TechDraw/Gui/QGIEdge.cpp index 009b9f9672..fc454acaf2 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.cpp +++ b/src/Mod/TechDraw/Gui/QGIEdge.cpp @@ -95,8 +95,8 @@ Qt::PenStyle QGIEdge::getHiddenStyle() Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); //Qt::PenStyle - NoPen, Solid, Dashed, ... - //Preferences::General - Solid, Dashed - Qt::PenStyle hidStyle = static_cast (hGrp->GetInt("HiddenLine",0) + 1); + //Preferences::General - Solid, Dashed + Qt::PenStyle hidStyle = static_cast (hGrp->GetInt("HiddenLine", 0) + 1); return hidStyle; } diff --git a/src/Mod/TechDraw/Gui/QGIEdge.h b/src/Mod/TechDraw/Gui/QGIEdge.h index 476c2f962a..13dba5d014 100644 --- a/src/Mod/TechDraw/Gui/QGIEdge.h +++ b/src/Mod/TechDraw/Gui/QGIEdge.h @@ -50,7 +50,7 @@ public: void setSmoothEdge(bool b) { isSmoothEdge = b; } bool getSmoothEdge() { return(isSmoothEdge); } virtual void setPrettyNormal() override; - + double getEdgeFuzz(void) const; protected: diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index af73319adc..45286624aa 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -73,13 +73,13 @@ QGIFace::QGIFace(int index) : m_segCount = 0; // setFillMode(NoFill); isHatched(false); - setFlag(QGraphicsItem::ItemClipsChildrenToShape,true); + setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); //setStyle(Qt::NoPen); //don't draw face lines, just fill for debugging setStyle(Qt::DashLine); m_geomColor = QColor(Qt::black); setLineWeight(0.5); //0 = cosmetic - + setPrettyNormal(); m_texture = QPixmap(); //empty texture @@ -93,7 +93,7 @@ QGIFace::QGIFace(int index) : m_fillScale = 1.0; getParameters(); - + m_styleDef = Qt::SolidPattern; m_styleSelect = Qt::SolidPattern; @@ -113,14 +113,14 @@ QGIFace::~QGIFace() //nothing to do. every item is a child of QGIFace & will get removed/deleted when QGIF is deleted } -void QGIFace::draw() +void QGIFace::draw() { setPath(m_outline); //Face boundary - if (isHatched()) { + if (isHatched()) { if (m_mode == GeomHatchFill) { //GeomHatch does not appear in pdf if clipping is set to true - setFlag(QGraphicsItem::ItemClipsChildrenToShape,false); + setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); if (!m_lineSets.empty()) { m_brush.setTexture(QPixmap()); m_fillStyleCurrent = m_styleDef; @@ -138,13 +138,13 @@ void QGIFace::draw() loadSvgHatch(m_fileSpec); if (m_hideSvgTiles) { //bitmap hatch doesn't need clipping - setFlag(QGraphicsItem::ItemClipsChildrenToShape,false); + setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); buildPixHatch(); m_rect->hide(); m_image->show(); } else { //SVG tiles need to be clipped - setFlag(QGraphicsItem::ItemClipsChildrenToShape,true); + setFlag(QGraphicsItem::ItemClipsChildrenToShape, true); buildSvgHatch(); m_image->hide(); m_rect->show(); @@ -203,13 +203,13 @@ void QGIFace::setHatchFile(std::string fileSpec) { m_fileSpec = fileSpec; } - + void QGIFace::loadSvgHatch(std::string fileSpec) { - QString qfs(QString::fromUtf8(fileSpec.data(),fileSpec.size())); + QString qfs(QString::fromUtf8(fileSpec.data(), fileSpec.size())); QFile f(qfs); if (!f.open(QFile::ReadOnly | QFile::Text)) { - Base::Console().Error("QGIFace could not read %s\n",fileSpec.c_str()); + Base::Console().Error("QGIFace could not read %s\n", fileSpec.c_str()); return; } m_svgXML = f.readAll(); @@ -260,7 +260,7 @@ void QGIFace::lineSetToFillItems(LineSet& ls) for (auto& g: ls.getGeoms()) { if (ls.isDashed()) { double offset = 0.0; - Base::Vector3d pStart = ls.getPatternStartPoint(g, offset,m_fillScale); + Base::Vector3d pStart = ls.getPatternStartPoint(g, offset, m_fillScale); offset = Rez::guiX(offset); Base::Vector3d gStart(g->getStartPoint().x, g->getStartPoint().y, @@ -268,17 +268,17 @@ void QGIFace::lineSetToFillItems(LineSet& ls) Base::Vector3d gEnd(g->getEndPoint().x, g->getEndPoint().y, 0.0); - if (DrawUtil::fpCompare(offset,0.0, 0.00001)) { //no offset + if (DrawUtil::fpCompare(offset, 0.0, 0.00001)) { //no offset QGraphicsPathItem* item1 = lineFromPoints(pStart, gEnd, ls.getDashSpec()); item1->setPen(pen); m_fillItems.push_back(item1); - if (!pStart.IsEqual(gStart,0.00001)) { + if (!pStart.IsEqual(gStart, 0.00001)) { QGraphicsPathItem* item2 = lineFromPoints(pStart, gStart, ls.getDashSpec().reversed()); item2->setPen(pen); m_fillItems.push_back(item2); } } else { //offset - pattern start not in g - double remain = dashRemain(decodeDashSpec(ls.getDashSpec()),offset); + double remain = dashRemain(decodeDashSpec(ls.getDashSpec()), offset); QGraphicsPathItem* shortItem = geomToStubbyLine(g, remain, ls); shortItem->setPen(pen); m_fillItems.push_back(shortItem); @@ -290,7 +290,7 @@ void QGIFace::lineSetToFillItems(LineSet& ls) } if (m_segCount > m_maxSeg) { - Base::Console().Warning("PAT segment count exceeded: %ld\n",m_segCount); + Base::Console().Warning("PAT segment count exceeded: %ld\n", m_segCount); break; } } @@ -300,7 +300,7 @@ QGraphicsPathItem* QGIFace::lineFromPoints(Base::Vector3d start, Base::Vector3d { QGraphicsPathItem* fillItem = new QGraphicsPathItem(this); fillItem->setPath(dashedPPath(decodeDashSpec(ds), - Rez::guiX(start), + Rez::guiX(start), Rez::guiX(end))); return fillItem; } @@ -315,7 +315,7 @@ QGraphicsPathItem* QGIFace::geomToLine(TechDraw::BaseGeomPtr base, LineSet& ls) base->getEndPoint().y, 0.0); fillItem->setPath(dashedPPath(decodeDashSpec(ls.getDashSpec()), - Rez::guiX(start), + Rez::guiX(start), Rez::guiX(end))); return fillItem; } @@ -332,10 +332,10 @@ QGraphicsPathItem* QGIFace::geomToStubbyLine(TechDraw::BaseGeomPtr base, double base->getEndPoint().y, 0.0); double origLen = (end - start).Length(); - + double appRemain = Rez::appX(remain); Base::Vector3d newEnd = start + (ls.getUnitDir() * appRemain); - + double newLen = (newEnd - start).Length(); if (newLen > origLen) { @@ -372,7 +372,7 @@ std::vector QGIFace::decodeDashSpec(DashSpec patDash) std::vector result; for (auto& d: patDash.get()) { double strokeLength; - if (DrawUtil::fpCompare(d,0.0)) { //pat dot + if (DrawUtil::fpCompare(d, 0.0)) { //pat dot strokeLength = penWidth; } else { //pat mark/space strokeLength = Rez::guiX(d); @@ -388,10 +388,10 @@ QPainterPath QGIFace::dashedPPath(const std::vector dv, const Base::Vect QPainterPath result; Base::Vector3d dir = (end - start); dir.Normalize(); - result.moveTo(start.x,-start.y); + result.moveTo(start.x, -start.y); Base::Vector3d currentPos = start; if (dv.empty()) { - result.lineTo(end.x,-end.y); + result.lineTo(end.x, -end.y); m_segCount++; } else { double lineLength = (end - start).Length(); @@ -400,7 +400,7 @@ QPainterPath QGIFace::dashedPPath(const std::vector dv, const Base::Vect while (travel < lineLength) { bool stop = false; if (m_segCount > 10000) { - Base::Console().Warning("PAT segment count exceeded: %ld\n",m_segCount); + Base::Console().Warning("PAT segment count exceeded: %ld\n", m_segCount); break; } @@ -412,9 +412,9 @@ QPainterPath QGIFace::dashedPPath(const std::vector dv, const Base::Vect stop = true; } if (d < 0.0) { - result.moveTo(segmentEnd.x,-segmentEnd.y); //space + result.moveTo(segmentEnd.x, -segmentEnd.y); //space } else { - result.lineTo(segmentEnd.x,-segmentEnd.y); //mark + result.lineTo(segmentEnd.x, -segmentEnd.y); //mark } if (stop) { break; @@ -450,7 +450,7 @@ std::vector QGIFace::offsetDash(const std::vector dv, const doub } i++; } - + double firstCell = accum - offset; if (dv.at(i) < 0.0) { //offset found in a space cell result.push_back(-1.0* firstCell); @@ -461,7 +461,7 @@ std::vector QGIFace::offsetDash(const std::vector dv, const doub for ( ; iCell < dv.size() ; iCell++) { result.push_back(dv.at(iCell)); } - + return result; } @@ -512,7 +512,7 @@ void QGIFace::makeMark(double x, double y) { QGICMark* cmItem = new QGICMark(-1); cmItem->setParentItem(this); - cmItem->setPos(x,y); + cmItem->setPos(x, y); cmItem->setThick(1.0); cmItem->setSize(40.0); cmItem->setZValue(ZVALUE::VERTEX); @@ -530,13 +530,13 @@ void QGIFace::buildSvgHatch() double nh = ceil(h / hTile); w = nw * wTile; h = nh * hTile; - m_rect->setRect(0.,0.,w,-h); + m_rect->setRect(0., 0., w,-h); m_rect->centerAt(fCenter); r = m_rect->rect(); - QByteArray before,after; + QByteArray before, after; before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8(); after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8(); - QByteArray colorXML = m_svgXML.replace(before,after); + QByteArray colorXML = m_svgXML.replace(before, after); long int tileCount = 0; for (int iw = 0; iw < int(nw); iw++) { for (int ih = 0; ih < int(nh); ih++) { @@ -544,11 +544,11 @@ void QGIFace::buildSvgHatch() tile->setScale(m_fillScale); if (tile->load(&colorXML)) { tile->setParentItem(m_rect); - tile->setPos(iw*wTile,-h + ih*hTile); + tile->setPos(iw*wTile, -h + ih*hTile); } tileCount++; if (tileCount > m_maxTile) { - Base::Console().Warning("SVG tile count exceeded: %ld\n",tileCount); + Base::Console().Warning("SVG tile count exceeded: %ld\n", tileCount); break; } } @@ -576,14 +576,14 @@ void QGIFace::buildPixHatch() w = nw * wTile; h = nh * hTile; - m_rect->setRect(0.,0.,w,-h); + m_rect->setRect(0., 0., w,-h); m_rect->centerAt(fCenter); r = m_rect->rect(); - QByteArray before,after; + QByteArray before, after; before = QString::fromStdString(SVGCOLPREFIX + SVGCOLDEFAULT).toUtf8(); after = QString::fromStdString(SVGCOLPREFIX + m_svgCol).toUtf8(); - QByteArray colorXML = m_svgXML.replace(before,after); + QByteArray colorXML = m_svgXML.replace(before, after); QSvgRenderer renderer; bool success = renderer.load(colorXML); if (!success) { @@ -629,7 +629,7 @@ void QGIFace::buildPixHatch() QRectF(0, 0, wTile, hTile)); //source rect tileCount++; if (tileCount > m_maxTile) { - Base::Console().Warning("Pixmap tile count exceeded: %ld\n",tileCount); + Base::Console().Warning("Pixmap tile count exceeded: %ld\n", tileCount); break; } } @@ -658,7 +658,7 @@ QPixmap QGIFace::textureFromSvg(std::string fileSpec) pixMap.fill(Qt::white); //try Qt::transparent? QPainter painter(&pixMap); renderer.render(&painter); //svg texture -> bitmap - result = pixMap.scaled(m_fillScale,m_fillScale); + result = pixMap.scaled(m_fillScale, m_fillScale); } //else return empty pixmap return result; } @@ -684,10 +684,10 @@ QPixmap QGIFace::textureFromBitmap(std::string fileSpec) { QPixmap pix; - QString qfs(QString::fromUtf8(fileSpec.data(),fileSpec.size())); + QString qfs(QString::fromUtf8(fileSpec.data(), fileSpec.size())); QFile f(qfs); if (!f.open(QFile::ReadOnly)) { - Base::Console().Error("QGIFace could not read %s\n",fileSpec.c_str()); + Base::Console().Error("QGIFace could not read %s\n", fileSpec.c_str()); return pix; } QByteArray bytes = f.readAll(); @@ -704,11 +704,11 @@ void QGIFace::getParameters() Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT"); - m_maxSeg = hGrp->GetInt("MaxSeg",10000l); + m_maxSeg = hGrp->GetInt("MaxSeg", 10000l); hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); - m_maxTile = hGrp->GetInt("MaxSVGTile",10000l); + m_maxTile = hGrp->GetInt("MaxSVGTile", 10000l); hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); @@ -717,7 +717,7 @@ void QGIFace::getParameters() hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/Colors"); - m_defClearFace = hGrp->GetBool("ClearFace",false); + m_defClearFace = hGrp->GetBool("ClearFace", false); } QRectF QGIFace::boundingRect() const diff --git a/src/Mod/TechDraw/Gui/QGIFace.h b/src/Mod/TechDraw/Gui/QGIFace.h index fac417db27..dc0000d160 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.h +++ b/src/Mod/TechDraw/Gui/QGIFace.h @@ -75,7 +75,7 @@ public: void setPrettySel() override; void setDrawEdges(bool b); virtual void setOutline(const QPainterPath& path); - + //shared fill parms void isHatched(bool s) {m_isHatched = s; } bool isHatched() {return m_isHatched;} @@ -84,7 +84,7 @@ public: //general hatch parms & methods void setHatchColor(App::Color c); void setHatchScale(double s); - + //svg fill parms & methods void setHatchFile(std::string fileSpec); void loadSvgHatch(std::string fileSpec); @@ -121,7 +121,7 @@ protected: std::vector offsetDash(const std::vector dv, const double offset); QPainterPath dashedPPath(const std::vector dv, const Base::Vector3d start, const Base::Vector3d end); double dashRemain(const std::vector dv, const double offset); - double calcOffset(TechDraw::BaseGeomPtr g,TechDraw::LineSet ls); + double calcOffset(TechDraw::BaseGeomPtr g, TechDraw::LineSet ls); int projIndex; //index of face in Projection. -1 for SectionFace. QGCustomRect *m_rect; @@ -149,11 +149,11 @@ protected: private: QPixmap m_texture; // - + QPainterPath m_outline; // - + QPainterPath m_geomhatch; //crosshatch fill lines - + QColor m_geomColor; //color for crosshatch lines double m_geomWeight; //lineweight for crosshatch lines bool m_defClearFace; diff --git a/src/Mod/TechDraw/Gui/QGIGhostHighlight.cpp b/src/Mod/TechDraw/Gui/QGIGhostHighlight.cpp index dadd2e6880..b97d945fbd 100644 --- a/src/Mod/TechDraw/Gui/QGIGhostHighlight.cpp +++ b/src/Mod/TechDraw/Gui/QGIGhostHighlight.cpp @@ -72,7 +72,7 @@ QGIGhostHighlight::~QGIGhostHighlight() void QGIGhostHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event) { // Base::Console().Message("QGIGhostHighlight::mousePress() - %X\n", this); - if ( (event->button() == Qt::LeftButton) && + if ( (event->button() == Qt::LeftButton) && (flags() & QGraphicsItem::ItemIsMovable) ) { m_dragging = true; event->accept(); @@ -82,7 +82,7 @@ void QGIGhostHighlight::mousePressEvent(QGraphicsSceneMouseEvent * event) void QGIGhostHighlight::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGIGhostHighlight::mouseRelease() - pos: %s scenePos: %s\n", +// Base::Console().Message("QGIGhostHighlight::mouseRelease() - pos: %s scenePos: %s\n", // DrawUtil::formatVector(pos()).c_str(), // DrawUtil::formatVector(mapToScene(pos())).c_str()); if (m_dragging) { diff --git a/src/Mod/TechDraw/Gui/QGIHighlight.cpp b/src/Mod/TechDraw/Gui/QGIHighlight.cpp index cd10431bca..3a6ff4b3fd 100644 --- a/src/Mod/TechDraw/Gui/QGIHighlight.cpp +++ b/src/Mod/TechDraw/Gui/QGIHighlight.cpp @@ -79,7 +79,7 @@ void QGIHighlight::draw() void QGIHighlight::makeHighlight() { - QRectF r(m_start,m_end); + QRectF r(m_start, m_end); m_circle->setRect(r); m_rect->setRect(r); if (getHoleStyle() == 0) { @@ -99,10 +99,10 @@ void QGIHighlight::makeReference() m_reference->setPlainText(m_refText); double fudge = Rez::guiX(1.0); QPointF newPos(m_end.x() + fudge, m_start.y() - m_refSize - fudge); - m_reference->setPos(newPos); + m_reference->setPos(newPos); double highRot = rotation(); - if (!TechDraw::DrawUtil::fpCompare(highRot,0.0)) { + if (!TechDraw::DrawUtil::fpCompare(highRot, 0.0)) { QRectF refBR = m_reference->boundingRect(); QPointF refCenter = refBR.center(); m_reference->setTransformOriginPoint(refCenter); @@ -119,10 +119,10 @@ void QGIHighlight::setInteractive(bool state) setFlag(QGraphicsItem::ItemSendsGeometryChanges, state); } -void QGIHighlight::setBounds(double x1,double y1,double x2,double y2) +void QGIHighlight::setBounds(double x1, double y1, double x2, double y2) { - m_start = QPointF(Rez::guiX(x1),Rez::guiX(-y1)); - m_end = QPointF(Rez::guiX(x2),Rez::guiX(-y2)); + m_start = QPointF(Rez::guiX(x1), Rez::guiX(-y1)); + m_end = QPointF(Rez::guiX(x2), Rez::guiX(-y2)); } void QGIHighlight::setReference(const char* ref) diff --git a/src/Mod/TechDraw/Gui/QGIHighlight.h b/src/Mod/TechDraw/Gui/QGIHighlight.h index 750093c220..e48c25715b 100644 --- a/src/Mod/TechDraw/Gui/QGIHighlight.h +++ b/src/Mod/TechDraw/Gui/QGIHighlight.h @@ -50,10 +50,10 @@ public: int type() const override { return Type;} virtual void paint(QPainter * painter, - const QStyleOptionGraphicsItem * option, + const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override; - void setBounds(double x1,double y1,double x2,double y2); + void setBounds(double x1, double y1, double x2, double y2); void setReference(const char* sym); void setFont(QFont f, double fsize); virtual void draw() override; diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp index 3c87f34c02..7ba5181c05 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.cpp @@ -61,9 +61,6 @@ #include "PreferencesGui.h" #include "QGIArrow.h" #include "ViewProviderLeader.h" -#include "MDIViewPage.h" -#include "DrawGuiUtil.h" -#include "QGVPage.h" #include "QGIPrimPath.h" #include "QGEPath.h" @@ -90,15 +87,15 @@ QGILeaderLine::QGILeaderLine() : setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); - + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); + setCacheMode(QGraphicsItem::NoCache); m_line = new QGIPrimPath(); addToGroup(m_line); m_line->setFlag(QGraphicsItem::ItemIsSelectable, false); m_line->setAcceptHoverEvents(false); - m_line->setPos(0.0,0.0); + m_line->setPos(0.0, 0.0); m_editPath = new QGEPath(this); addToGroup(m_editPath); @@ -111,7 +108,7 @@ QGILeaderLine::QGILeaderLine() : m_arrow1 = new QGIArrow(); addToGroup(m_arrow1); - m_arrow1->setPos(0.0,0.0); + m_arrow1->setPos(0.0, 0.0); m_arrow1->hide(); m_arrow2 = new QGIArrow(); addToGroup(m_arrow2); @@ -133,7 +130,7 @@ void QGILeaderLine::setLeaderFeature(TechDraw::DrawLeaderLine* feat) float x = Rez::guiX(feat->X.getValue()); float y = Rez::guiX(-feat->Y.getValue()); - setPos(x,y); + setPos(x, y); setNormalColorAll(); setPrettyNormal(); @@ -160,20 +157,20 @@ QVariant QGILeaderLine::itemChange(GraphicsItemChange change, const QVariant &va //QGILL isn't draggable so skip QGIV::mousePress have event void QGILeaderLine::mousePressEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGILL::mousePressEvent() - %s\n",getViewName()); +// Base::Console().Message("QGILL::mousePressEvent() - %s\n", getViewName()); QGraphicsItem::mousePressEvent(event); } //QGILL isn't draggable so skip QGIV::mouseRelease void QGILeaderLine::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGILL::mouseReleaseEvent() - %s\n",getViewName()); +// Base::Console().Message("QGILL::mouseReleaseEvent() - %s\n", getViewName()); QGraphicsItem::mouseReleaseEvent(event); } void QGILeaderLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { -// Base::Console().Message("QGILL::hoverEnter() - selected; %d\n",isSelected()); +// Base::Console().Message("QGILL::hoverEnter() - selected; %d\n", isSelected()); m_hasHover = true; if (!isSelected()) { setPrettyPre(); @@ -183,7 +180,7 @@ void QGILeaderLine::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { -// Base::Console().Message("QGILL::hoverLeave() - selected; %d\n",isSelected()); +// Base::Console().Message("QGILL::hoverLeave() - selected; %d\n", isSelected()); m_hasHover = false; if(!isSelected()) { setPrettyNormal(); @@ -193,7 +190,7 @@ void QGILeaderLine::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent) { -// Base::Console().Message("QGILL::onSoureChange(%s)\n",newParent->getNameInDocument()); +// Base::Console().Message("QGILL::onSoureChange(%s)\n", newParent->getNameInDocument()); std::string parentName = newParent->getNameInDocument(); QGIView* qgiParent = getQGIVByName(parentName); if (qgiParent) { @@ -201,7 +198,7 @@ void QGILeaderLine::onSourceChange(TechDraw::DrawView* newParent) setParentItem(m_parentItem); draw(); } else { - Base::Console().Warning("QGILL::onSourceChange - new parent %s has no QGIView\n",parentName.c_str()); + Base::Console().Warning("QGILL::onSourceChange - new parent %s has no QGIView\n", parentName.c_str()); } } @@ -242,14 +239,14 @@ void QGILeaderLine::closeEdit() { // Base::Console().Message("QGIL::closeEdit()\n"); if (m_editPath) { - m_editPath->onEndEdit(); //tell QEPath that edit session ended + m_editPath->onEndEdit(); //tell QEPath that edit session ended } } //signaled from QEPath void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector points) { -// Base::Console().Message("QGILL::onLineEditFinished(%s, %d)\n", +// Base::Console().Message("QGILL::onLineEditFinished(%s, %d)\n", // TechDraw::DrawUtil::formatVector(tipDisplace).c_str(), // points.size()); m_blockDraw = true; @@ -258,8 +255,8 @@ void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector return; double baseScale = featLeader->getBaseScale(); - if ( !(TechDraw::DrawUtil::fpCompare(tipDisplace.x(),0.0) && - TechDraw::DrawUtil::fpCompare(tipDisplace.y(),0.0)) ) { + if ( !(TechDraw::DrawUtil::fpCompare(tipDisplace.x(), 0.0) && + TechDraw::DrawUtil::fpCompare(tipDisplace.y(), 0.0)) ) { //tip was moved. need to change AttachPoint QPointF oldAttach = getAttachFromFeature(); QPointF newAttach = oldAttach + (tipDisplace / baseScale); @@ -271,7 +268,7 @@ void QGILeaderLine::onLineEditFinished(QPointF tipDisplace, std::vector std::vector waypoints; for (auto& p: points) { QPointF moved = p - tipDisplace; - Base::Vector3d v(moved.x(),moved.y(),0.0); + Base::Vector3d v(moved.x(), moved.y(), 0.0); waypoints.push_back(v); } waypoints.at(0) = Base::Vector3d(0.0, 0.0, 0.0); @@ -329,7 +326,7 @@ void QGILeaderLine::restoreState() void QGILeaderLine::updateView(bool update) { -// Base::Console().Message("QGIL::updateView() %s\n",getViewObject()->getNameInDocument()); +// Base::Console().Message("QGIL::updateView() %s\n", getViewObject()->getNameInDocument()); Q_UNUSED(update); auto featLeader( dynamic_cast(getViewObject()) ); if (!featLeader) { @@ -375,7 +372,7 @@ void QGILeaderLine::draw() double baseScale = featLeader->getBaseScale(); double x = Rez::guiX(featLeader->X.getValue()); double y = - Rez::guiX(featLeader->Y.getValue()); - QPointF aPoint(x,y); + QPointF aPoint(x, y); aPoint *= baseScale; setPos(aPoint); @@ -383,7 +380,7 @@ void QGILeaderLine::draw() m_line->setStyle(m_lineStyle); m_line->setWidth(getLineWidth()); - m_line->setPos(0,0); //make m_line coords == leader coords + m_line->setPos(0, 0); //make m_line coords == leader coords std::vector qPoints = getWayPointsFromFeature(); if (featLeader->Scalable.getValue()) { @@ -416,9 +413,9 @@ QPainterPath QGILeaderLine::makeLeaderPath(std::vector qPoints) return result; } - QPointF startAdjVec(0.0,0.0); + QPointF startAdjVec(0.0, 0.0); double startAdjLength(0.0); - QPointF endAdjVec(0.0,0.0); + QPointF endAdjVec(0.0, 0.0); double endAdjLength(0.0); if (qPoints.size() > 1) { //make path adjustment to hide leaderline ends behind arrowheads @@ -464,7 +461,7 @@ QPointF QGILeaderLine::getAttachFromFeature() } double x = Rez::guiX(featLeader->X.getValue()); double y = - Rez::guiX(featLeader->Y.getValue()); - result = QPointF(x,y); + result = QPointF(x, y); return result; } @@ -492,7 +489,7 @@ std::vector QGILeaderLine::getWayPointsFromFeature() void QGILeaderLine::setArrows(std::vector pathPoints) { // Base::Console().Message("QGILL::setArrows()\n"); - Base::Vector3d stdX(1.0,0.0,0.0); + Base::Vector3d stdX(1.0, 0.0, 0.0); TechDraw::DrawLeaderLine* featLeader = getFeature(); QPointF lastOffset = (pathPoints.back() - pathPoints.front()); @@ -509,16 +506,16 @@ void QGILeaderLine::setArrows(std::vector pathPoints) QPointF s = (*it); QPointF e = (*(it + 1)); QPointF qsVec = s - e; - Base::Vector3d sVec(qsVec.x(),qsVec.y(),0.0); + Base::Vector3d sVec(qsVec.x(), qsVec.y(), 0.0); m_arrow1->setDirection(sVec); - m_arrow1->setPos(0.0,0.0); + m_arrow1->setPos(0.0, 0.0); } m_arrow1->draw(); m_arrow1->show(); } else { m_arrow1->hide(); } - + if (featLeader->EndSymbol.getValue() != ArrowType::NONE) { m_arrow2->setStyle(featLeader->EndSymbol.getValue()); m_arrow2->setWidth(getLineWidth()); @@ -529,7 +526,7 @@ void QGILeaderLine::setArrows(std::vector pathPoints) QPointF s = (*itr); QPointF e = (*(itr + 1)); QPointF qeVec = s - e; - Base::Vector3d eVec(qeVec.x(),qeVec.y(),0.0); + Base::Vector3d eVec(qeVec.x(), qeVec.y(), 0.0); m_arrow2->setDirection(eVec); m_arrow2->setPos(lastOffset); } @@ -567,7 +564,7 @@ double QGILeaderLine::getLineWidth() TechDraw::DrawLeaderLine* QGILeaderLine::getFeature() { - TechDraw::DrawLeaderLine* result = + TechDraw::DrawLeaderLine* result = static_cast(getViewObject()); return result; } @@ -577,23 +574,16 @@ double QGILeaderLine::getEdgeFuzz() const return PreferencesGui::edgeFuzz(); } -QColor QGILeaderLine::getNormalColor() +QColor QGILeaderLine::prefNormalColor() { // Base::Console().Message("QGILL::getNormalColor()\n"); - m_colNormal = PreferencesGui::leaderQColor(); + setNormalColor(PreferencesGui::leaderQColor()); - auto lead( dynamic_cast(getViewObject()) ); - if (!lead) -// Base::Console().Message("QGILL::getNormalColor - no feature\n"); - return m_colNormal; - - auto vp = static_cast(getViewProvider(getViewObject())); - if (!vp) -// Base::Console().Message("QGILL::getNormalColor - no viewProvider\n"); - return m_colNormal; - - m_colNormal = vp->Color.getValue().asValue(); - return m_colNormal; + auto vp = dynamic_cast(getViewProvider(getViewObject())); + if (vp) { + setNormalColor(vp->Color.getValue().asValue()); + } + return getNormalColor(); } QRectF QGILeaderLine::boundingRect() const diff --git a/src/Mod/TechDraw/Gui/QGILeaderLine.h b/src/Mod/TechDraw/Gui/QGILeaderLine.h index ac45b19140..6cd8e22306 100644 --- a/src/Mod/TechDraw/Gui/QGILeaderLine.h +++ b/src/Mod/TechDraw/Gui/QGILeaderLine.h @@ -59,7 +59,7 @@ public: enum {Type = QGraphicsItem::UserType + 232}; explicit QGILeaderLine(); - ~QGILeaderLine() override = default; + ~QGILeaderLine() = default; int type() const override { return Type;} void paint( QPainter * painter, @@ -77,7 +77,7 @@ public: void abandonEdit(); void closeEdit(); - + double getLineWidth(); double getEdgeFuzz() const; @@ -93,7 +93,7 @@ public: void setLeaderFeature(TechDraw::DrawLeaderLine* feat); public Q_SLOTS: - void onLineEditFinished(QPointF attach, std::vector deltas); //QGEPath is finished editing points + void onLineEditFinished(QPointF tipDisplace, std::vector points); //QGEPath is finished editing points void onSourceChange(TechDraw::DrawView* newParent) override; Q_SIGNALS: @@ -107,15 +107,15 @@ protected: QVariant itemChange( GraphicsItemChange change, const QVariant &value ) override; - std::vector m_pathPoints; - + void saveState(); void restoreState(); -protected: - QColor getNormalColor() override; + QColor prefNormalColor(); void setNormalColorAll(); +private: + std::vector m_pathPoints; QGraphicsItem* m_parentItem; QGIPrimPath* m_line; //actual leader line double m_lineWidth; diff --git a/src/Mod/TechDraw/Gui/QGIMatting.cpp b/src/Mod/TechDraw/Gui/QGIMatting.cpp index c462168838..2bab22f596 100644 --- a/src/Mod/TechDraw/Gui/QGIMatting.cpp +++ b/src/Mod/TechDraw/Gui/QGIMatting.cpp @@ -84,16 +84,16 @@ void QGIMatting::draw() 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); + QRectF outline(-m_width, -m_height, 2.0 * m_width, 2.0 * m_height); QPainterPath ppOut; ppOut.addRect(outline); QPainterPath ppCut; if (getHoleStyle() == 0) { - QRectF roundCutout (-m_radius,-m_radius,2.0 * m_radius,2.0 * m_radius); + QRectF roundCutout (-m_radius, -m_radius, 2.0 * m_radius, 2.0 * m_radius); ppCut.addEllipse(roundCutout); } else { double squareSize = m_radius; - QRectF squareCutout (-squareSize,-squareSize,2.0 * squareSize,2.0 * squareSize); + QRectF squareCutout (-squareSize, -squareSize, 2.0 * squareSize, 2.0 * squareSize); ppCut.addRect(squareCutout); } ppOut.addPath(ppCut); @@ -112,7 +112,7 @@ int QGIMatting::getHoleStyle() QRectF QGIMatting::boundingRect() const { QRectF result ; - result = childrenBoundingRect().adjusted(-1,-1,1,1); + result = childrenBoundingRect().adjusted(-1, -1, 1,1); return result; } @@ -120,7 +120,7 @@ void QGIMatting::paint ( QPainter * painter, const QStyleOptionGraphicsItem * op QStyleOptionGraphicsItem myOption(*option); myOption.state &= ~QStyle::State_Selected; - //painter->drawRect(boundingRect().adjusted(-2.0,-2.0,2.0,2.0)); + //painter->drawRect(boundingRect().adjusted(-2.0, -2.0, 2.0, 2.0)); QGraphicsItemGroup::paint (painter, &myOption, widget); } diff --git a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp index 474ab003c0..9328b402ca 100644 --- a/src/Mod/TechDraw/Gui/QGIPrimPath.cpp +++ b/src/Mod/TechDraw/Gui/QGIPrimPath.cpp @@ -53,7 +53,7 @@ QGIPrimPath::QGIPrimPath(): setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setAcceptHoverEvents(true); isHighlighted = false; @@ -81,7 +81,7 @@ QGIPrimPath::QGIPrimPath(): QVariant QGIPrimPath::itemChange(GraphicsItemChange change, const QVariant &value) { -// Base::Console().Message("QGIPP::itemChange(%d) - type: %d\n", change,type() - QGraphicsItem::UserType); +// Base::Console().Message("QGIPP::itemChange(%d) - type: %d\n", change, type() - QGraphicsItem::UserType); if (change == ItemSelectedHasChanged && scene()) { if(isSelected()) { setPrettySel(); @@ -94,7 +94,7 @@ QVariant QGIPrimPath::itemChange(GraphicsItemChange change, const QVariant &valu void QGIPrimPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { -// Base::Console().Message("QGIPP::hoverEnter() - selected; %d\n",isSelected()); +// Base::Console().Message("QGIPP::hoverEnter() - selected; %d\n", isSelected()); if (!isSelected()) { setPrettyPre(); } @@ -103,11 +103,11 @@ void QGIPrimPath::hoverEnterEvent(QGraphicsSceneHoverEvent *event) void QGIPrimPath::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { -// Base::Console().Message("QGIPP::hoverLeave() - selected; %d\n",isSelected()); +// Base::Console().Message("QGIPP::hoverLeave() - selected; %d\n", isSelected()); if(!isSelected()) { setPrettyNormal(); } - + QGraphicsPathItem::hoverLeaveEvent(event); } @@ -315,7 +315,7 @@ void QGIPrimPath::resetFill() { //set PlainFill void QGIPrimPath::setFillColor(QColor c) -{ +{ m_colNormalFill = c; m_fillColorCurrent = m_colNormalFill; // m_colDefFill = c; diff --git a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp index 406b86dd3f..c09937973d 100644 --- a/src/Mod/TechDraw/Gui/QGIProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/QGIProjGroup.cpp @@ -169,7 +169,7 @@ void QGIProjGroup::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) } } else if(scene() && qAnchor) { // End of Drag - getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getY())); + getViewObject()->setPosition(Rez::appX(x()), Rez::appX(getY())); } } QGIViewCollection::mouseReleaseEvent(event); @@ -200,7 +200,7 @@ QGIView * QGIProjGroup::getAnchorQItem() const void QGIProjGroup::rotateView() { Base::Console().Warning("QGIPG: Projection Groups do not rotate. Change ignored\n"); -} +} void QGIProjGroup::drawBorder() { diff --git a/src/Mod/TechDraw/Gui/QGIRichAnno.cpp b/src/Mod/TechDraw/Gui/QGIRichAnno.cpp index b6f06e2fa8..c395e54cea 100644 --- a/src/Mod/TechDraw/Gui/QGIRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/QGIRichAnno.cpp @@ -95,7 +95,7 @@ QGIRichAnno::QGIRichAnno() : setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); m_text = new QGCustomText(); m_text->setTextInteractionFlags(Qt::NoTextInteraction); @@ -107,7 +107,7 @@ QGIRichAnno::QGIRichAnno() : addToGroup(m_rect); m_rect->setZValue(ZVALUE::DIMENSION - 1); m_rect->centerAt(0.0, 0.0); - + setZValue(ZVALUE::DIMENSION); } @@ -157,7 +157,7 @@ void QGIRichAnno::drawBorder() void QGIRichAnno::draw() { -// Base::Console().Log("QGIRA::draw() - %s - parent: %X\n",getFeature()->getNameInDocument(), parentItem()); +// Base::Console().Log("QGIRA::draw() - %s - parent: %X\n", getFeature()->getNameInDocument(), parentItem()); if (!isVisible()) // Base::Console().Message("QGIRA::draw - not visible\n"); return; @@ -180,14 +180,14 @@ void QGIRichAnno::draw() void QGIRichAnno::setTextItem() { -// Base::Console().Message("QGIRA::setTextItem() - %s\n",getViewName()); +// Base::Console().Message("QGIRA::setTextItem() - %s\n", getViewName()); TechDraw::DrawRichAnno* annoFeat = getFeature(); QString inHtml = QString::fromUtf8(annoFeat->AnnoText.getValue()); - //don't do this multiplication if exporting to SVG as other apps interpret + //don't do this multiplication if exporting to SVG as other apps interpret //font sizes differently from QGraphicsTextItem (?) if (!getExporting()) { - //convert point font sizes to (Rez,mm) font sizes + //convert point font sizes to (Rez, mm) font sizes QRegExp rxFontSize(QString::fromUtf8("font-size:([0-9]*)pt;")); double mmPerPoint = 0.353; double sizeConvert = Rez::getRezFactor() * mmPerPoint; @@ -197,13 +197,13 @@ void QGIRichAnno::setTextItem() while ((pos = rxFontSize.indexIn(inHtml, pos)) != -1) { QString found = rxFontSize.cap(0); findList << found; - QString qsOldSize = rxFontSize.cap(1); + QString qsOldSize = rxFontSize.cap(1); QString repl = found; double newSize = qsOldSize.toDouble(); newSize = newSize * sizeConvert; QString qsNewSize = QString::number(newSize, 'f', 2); - repl.replace(qsOldSize,qsNewSize); + repl.replace(qsOldSize, qsNewSize); replList << repl; pos += rxFontSize.matchedLength(); } @@ -220,7 +220,7 @@ void QGIRichAnno::setTextItem() // m_text->update(); if (annoFeat->ShowFrame.getValue()) { - QRectF r = m_text->boundingRect().adjusted(1,1,-1,-1); + QRectF r = m_text->boundingRect().adjusted(1, 1,-1, -1); m_rect->setPen(rectPen()); m_rect->setBrush(Qt::NoBrush); m_rect->setRect(r); @@ -273,15 +273,15 @@ void QGIRichAnno::setLineSpacing(int lineSpacing) TechDraw::DrawRichAnno* QGIRichAnno::getFeature() { - TechDraw::DrawRichAnno* result = + TechDraw::DrawRichAnno* result = static_cast(getViewObject()); return result; } QRectF QGIRichAnno::boundingRect() const { - QRectF rect = mapFromItem(m_text,m_text->boundingRect()).boundingRect(); - return rect.adjusted(-10.,-10.,10.,10.); + QRectF rect = mapFromItem(m_text, m_text->boundingRect()).boundingRect(); + return rect.adjusted(-10., -10., 10., 10.); } void QGIRichAnno::paint ( QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget) { @@ -306,7 +306,7 @@ QPen QGIRichAnno::rectPen() const double rectWeight = Rez::guiX(vp->LineWidth.getValue()); Qt::PenStyle rectStyle = (Qt::PenStyle) vp->LineStyle.getValue(); App::Color temp = vp->LineColor.getValue(); - QColor rectColor = temp.asValue(); + QColor rectColor = temp.asValue(); pen = QPen(rectStyle); pen.setWidthF(rectWeight); @@ -326,7 +326,7 @@ double QGIRichAnno::prefPointSize() //this conversion is only approximate. the factor changes for different fonts. // double mmToPts = 2.83; //theoretical value double mmToPts = 2.00; //practical value. seems to be reasonable for common fonts. - + double ptsSize = round(fontSize * mmToPts); return ptsSize; } diff --git a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp index 3df35c26a1..27b6a19b57 100644 --- a/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp +++ b/src/Mod/TechDraw/Gui/QGISVGTemplate.cpp @@ -214,7 +214,7 @@ void QGISVGTemplate::createClickHandles() myPen.setWidth(0); // 0 means "cosmetic pen" - always 1px item->setPen(myPen); - QBrush myBrush(editClickBoxColor,Qt::SolidPattern); + QBrush myBrush(editClickBoxColor, Qt::SolidPattern); item->setBrush(myBrush); item->setZValue(ZVALUE::SVGTEMPLATE + 1); diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.cpp b/src/Mod/TechDraw/Gui/QGISectionLine.cpp index 04d62ee0e3..198a5d0923 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.cpp +++ b/src/Mod/TechDraw/Gui/QGISectionLine.cpp @@ -120,7 +120,7 @@ void QGISectionLine::makeArrowsISO() { double arrowRotation = 0.0; m_arrowDir.Normalize(); - double angle = atan2f(m_arrowDir.y,m_arrowDir.x); + double angle = atan2f(m_arrowDir.y, m_arrowDir.x); if (angle < 0.0) { angle = 2 * M_PI + angle; } @@ -144,14 +144,14 @@ void QGISectionLine::makeArrowsTrad() { double arrowRotation = 0.0; m_arrowDir.Normalize(); - double angle = atan2f(m_arrowDir.y,m_arrowDir.x); + double angle = atan2f(m_arrowDir.y, m_arrowDir.x); if (angle < 0.0) { angle = 2 * M_PI + angle; } arrowRotation = 360.0 - angle * (180.0/M_PI); //convert to Qt rotation (clockwise degrees) - QPointF posArrow1,posArrow2; - QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y); //remember Y dir is flipped + QPointF posArrow1, posArrow2; + QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y); //remember Y dir is flipped double oblique = 1.0; if ( !DrawUtil::fpCompare((m_arrowDir.x + m_arrowDir.y), 1.0) ) { @@ -199,7 +199,7 @@ void QGISectionLine::makeSymbolsTrad() double symWidth = symRect.width(); double symHeight = symRect.height(); double symbolFudge = 0.75; - double angle = atan2f(m_arrowDir.y,m_arrowDir.x); + double angle = atan2f(m_arrowDir.y, m_arrowDir.x); if (angle < 0.0) { angle = 2 * M_PI + angle; } @@ -262,7 +262,7 @@ void QGISectionLine::makeSymbolsISO() void QGISectionLine::extensionEndsTrad() { - QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y); + QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y); //extensions for oblique section line needs to be a bit longer double oblique = 1.0; @@ -270,7 +270,7 @@ void QGISectionLine::extensionEndsTrad() oblique = 1.25; } - //draw from section line endpoint + //draw from section line endpoint QPointF offsetEnd = oblique * m_extLen * offsetDir; m_beginExt1 = m_start; m_endExt1 = m_start + offsetEnd; @@ -281,7 +281,7 @@ void QGISectionLine::extensionEndsTrad() void QGISectionLine::extensionEndsISO() { //lines are offset to other side of section line! - QPointF offsetDir(m_arrowDir.x,-m_arrowDir.y); + QPointF offsetDir(m_arrowDir.x, -m_arrowDir.y); offsetDir = offsetDir * -1.0; //extensions for oblique section line needs to be a bit longer? @@ -291,7 +291,7 @@ void QGISectionLine::extensionEndsISO() oblique = 1.10; } - //draw from section line endpoint less arrow length + //draw from section line endpoint less arrow length QPointF offsetStart = offsetDir * Rez::guiX(QGIArrow::getPrefArrowSize()); QPointF offsetEnd = oblique * m_extLen * offsetDir; @@ -309,10 +309,10 @@ void QGISectionLine::setEnds(Base::Vector3d l1, Base::Vector3d l2) m_end = QPointF(l2.x, l2.y); } -void QGISectionLine::setBounds(double x1,double y1,double x2,double y2) +void QGISectionLine::setBounds(double x1, double y1, double x2, double y2) { - m_start = QPointF(x1,y1); - m_end = QPointF(x2,y2); + m_start = QPointF(x1, y1); + m_end = QPointF(x2, y2); } void QGISectionLine::setSymbol(char* sym) @@ -320,9 +320,9 @@ void QGISectionLine::setSymbol(char* sym) m_symbol = sym; } -void QGISectionLine::setDirection(double xDir,double yDir) +void QGISectionLine::setDirection(double xDir, double yDir) { - Base::Vector3d newDir(xDir,yDir,0.0); + Base::Vector3d newDir(xDir, yDir, 0.0); setDirection(newDir); } @@ -415,7 +415,7 @@ void QGISectionLine::setTools() // m_arrow2->setPen(m_pen); // m_arrow1->setBrush(m_brush); // m_arrow2->setBrush(m_brush); - + m_arrow1->setNormalColor(m_colCurrent); m_arrow1->setFillColor(m_colCurrent); m_arrow1->setPrettyNormal(); diff --git a/src/Mod/TechDraw/Gui/QGISectionLine.h b/src/Mod/TechDraw/Gui/QGISectionLine.h index 31eaed6337..fa23302ad3 100644 --- a/src/Mod/TechDraw/Gui/QGISectionLine.h +++ b/src/Mod/TechDraw/Gui/QGISectionLine.h @@ -52,9 +52,9 @@ public: virtual void paint(QPainter * painter, const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ); void setEnds(Base::Vector3d l1, Base::Vector3d l2); - void setBounds(double x1,double y1,double x2,double y2); + void setBounds(double x1, double y1, double x2, double y2); void setSymbol(char* sym); - void setDirection(double xDir,double yDir); + void setDirection(double xDir, double yDir); void setDirection(Base::Vector3d dir); void setFont(QFont f, double fsize); void setSectionStyle(int style); diff --git a/src/Mod/TechDraw/Gui/QGITile.cpp b/src/Mod/TechDraw/Gui/QGITile.cpp index fe3096fe08..6dd33ea6ba 100644 --- a/src/Mod/TechDraw/Gui/QGITile.cpp +++ b/src/Mod/TechDraw/Gui/QGITile.cpp @@ -75,7 +75,7 @@ QGITile::QGITile(TechDraw::DrawTileWeld* dtw) : m_qgTextL = new QGCustomText(); addToGroup(m_qgTextL); - + m_qgTextR = new QGCustomText(); addToGroup(m_qgTextR); @@ -96,9 +96,9 @@ QGITile::QGITile(TechDraw::DrawTileWeld* dtw) : setFlag(QGraphicsItem::ItemIsSelectable, false); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemStacksBehindParent, true); - + m_colNormal = prefNormalColor(); m_colCurrent = m_colNormal; } @@ -125,27 +125,27 @@ void QGITile::draw() if (m_row == 0) { //arrowSide double x = m_origin.x(); double y = m_origin.y() - (m_high * 0.5); //inverted y!! - setPos(x,y); + setPos(x, y); } else if (m_row == -1) { //otherSide if (getAltWeld()) { - if (isTailRight()) { + if (isTailRight()) { double x = m_origin.x() + (0.5 * totalWidth); //move to right 1/2 tile width double y = m_origin.y() + (m_high * 0.5); //inverted y!! - setPos(x,y); + setPos(x, y); } else { double x = m_origin.x() - (0.5 * totalWidth); //move to left 1/2 tile width double y = m_origin.y() + (m_high * 0.5); //inverted y!! - setPos(x,y); + setPos(x, y); } } else { double x = m_origin.x(); double y = m_origin.y() + (m_high * 0.5); //inverted y!! - setPos(x,y); + setPos(x, y); } } else { double x = m_origin.x() + m_col * totalWidth; double y = m_origin.y() - (m_row * m_high) - (m_high * 0.5); //inverted y!! - setPos(x,y); + setPos(x, y); } } @@ -165,7 +165,7 @@ void QGITile::makeSymbol() return; } m_qgSvg->setScale(getSymbolFactor()); - m_qgSvg->centerAt(0.0, 0.0); //(0,0) is based on symbol size + m_qgSvg->centerAt(0.0, 0.0); //(0, 0) is based on symbol size } void QGITile::makeText() @@ -284,7 +284,7 @@ void QGITile::setFont(std::string fName, double fSizePx) void QGITile::setSymbolFile(std::string s) { -// Base::Console().Message("QGIT::setSymbolFile(%s)\n",s.c_str()); +// Base::Console().Message("QGIT::setSymbolFile(%s)\n", s.c_str()); if (!s.empty()) { m_svgPath = QString::fromUtf8(s.c_str()); } @@ -346,7 +346,7 @@ double QGITile::getSymbolWidth() const { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); - double w = hGrp->GetFloat("SymbolSize",64); + double w = hGrp->GetFloat("SymbolSize", 64); // symbols are only nominally 64x64. they actually have a "border" of 4 - 0.5*stroke(0.5) // so we'll say effectively 62x62? 60 x 60 // double w = 64.0; @@ -360,7 +360,7 @@ double QGITile::getSymbolHeight() const { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Dimensions"); - double h = hGrp->GetFloat("SymbolSize",64); + double h = hGrp->GetFloat("SymbolSize", 64); double fudge = 4.0; h = h - fudge; // double h = 60.0; @@ -373,7 +373,7 @@ double QGITile::getSymbolFactor() const { Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); - double s = hGrp->GetFloat("SymbolFactor",1.25); + double s = hGrp->GetFloat("SymbolFactor", 1.25); // double s = 1.25; return s; } diff --git a/src/Mod/TechDraw/Gui/QGIView.cpp b/src/Mod/TechDraw/Gui/QGIView.cpp index 316977d36e..449730c526 100644 --- a/src/Mod/TechDraw/Gui/QGIView.cpp +++ b/src/Mod/TechDraw/Gui/QGIView.cpp @@ -52,7 +52,6 @@ #include "Rez.h" #include "ZVALUE.h" -#include "DrawGuiUtil.h" #include "QGSPage.h" #include "QGVPage.h" #include "QGCustomLabel.h" @@ -66,8 +65,6 @@ #include "ViewProviderDrawingView.h" #include "ViewProviderPage.h" #include "MDIViewPage.h" -#include "QGICMark.h" -#include "QGTracker.h" #include #include @@ -101,9 +98,10 @@ QGIView::QGIView() setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); - m_colCurrent = getNormalColor(); + m_colNormal = prefNormalColor(); + m_colCurrent = m_colNormal; m_pen.setColor(m_colCurrent); //Border/Label styling @@ -170,9 +168,9 @@ bool QGIView::isVisible() //Set selection state for this and it's children //required for items like dimensions & balloons -void QGIView::setGroupSelection(bool b) +void QGIView::setGroupSelection(bool isSelected) { - setSelected(b); + setSelected(isSelected); } void QGIView::alignTo(QGraphicsItem*item, const QString &alignment) @@ -183,7 +181,7 @@ void QGIView::alignTo(QGraphicsItem*item, const QString &alignment) QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) { - QPointF newPos(0.0,0.0); + QPointF newPos(0.0, 0.0); // Base::Console().Message("QGIV::itemChange(%d)\n", change); if(change == ItemPositionChange && scene()) { newPos = value.toPointF(); //position within parent! @@ -221,7 +219,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) m_colCurrent = getSelectColor(); // m_selectState = 2; } else { - m_colCurrent = getNormalColor(); + m_colCurrent = PreferencesGui::normalQColor(); // m_selectState = 0; } drawBorder(); @@ -232,7 +230,7 @@ QVariant QGIView::itemChange(GraphicsItemChange change, const QVariant &value) void QGIView::mousePressEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGIV::mousePressEvent() - %s\n",getViewName()); +// Base::Console().Message("QGIV::mousePressEvent() - %s\n", getViewName()); signalSelectPoint(this, event->pos()); if (m_dragState == NODRAG) { m_dragState = DRAGSTARTED; @@ -252,16 +250,16 @@ void QGIView::mouseMoveEvent(QGraphicsSceneMouseEvent * event) void QGIView::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { //TODO: this should be done in itemChange - item position has changed -// Base::Console().Message("QGIV::mouseReleaseEvent() - %s\n",getViewName()); +// Base::Console().Message("QGIV::mouseReleaseEvent() - %s\n", getViewName()); // if(scene() && this == scene()->mouseGrabberItem()) { if (m_dragState == DRAGGING) { if(!m_locked) { if (!isInnerView()) { double tempX = x(), tempY = getY(); - getViewObject()->setPosition(Rez::appX(tempX),Rez::appX(tempY)); + getViewObject()->setPosition(Rez::appX(tempX), Rez::appX(tempY)); } else { - getViewObject()->setPosition(Rez::appX(x()),Rez::appX(getYInClip(y()))); + getViewObject()->setPosition(Rez::appX(x()), Rez::appX(getYInClip(y()))); } } } @@ -289,29 +287,29 @@ void QGIView::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) if(isSelected()) { m_colCurrent = getSelectColor(); } else { - m_colCurrent = getNormalColor(); + m_colCurrent = PreferencesGui::normalQColor(); } drawBorder(); } //sets position in /Gui(graphics), not /App -void QGIView::setPosition(qreal x, qreal y) +void QGIView::setPosition(qreal xPos, qreal yPos) { -// Base::Console().Message("QGIV::setPosition(%.3f, %.3f) (gui)\n",x, y); - double newX = x; +// Base::Console().Message("QGIV::setPosition(%.3f, %.3f) (gui)\n", x, y); + double newX = xPos; double newY; double oldX = pos().x(); double oldY = pos().y(); if (!isInnerView()) { - newY = -y; + newY = -yPos; } else { - newY = getYInClip(y); + newY = getYInClip(yPos); } - if ( (TechDraw::DrawUtil::fpCompare(newX,oldX)) && - (TechDraw::DrawUtil::fpCompare(newY,oldY)) ) { + if ( (TechDraw::DrawUtil::fpCompare(newX, oldX)) && + (TechDraw::DrawUtil::fpCompare(newY, oldY)) ) { return; } else { - setPos(newX,newY); + setPos(newX, newY); } } @@ -342,7 +340,7 @@ QGIViewClip* QGIView::getClipGroup() void QGIView::updateView(bool forceUpdate) { -// Base::Console().Message("QGIV::updateView() - %s\n",getViewObject()->getNameInDocument()); +// Base::Console().Message("QGIV::updateView() - %s\n", getViewObject()->getNameInDocument()); //allow/prevent dragging if (getViewObject()->isLocked()) { @@ -358,7 +356,7 @@ void QGIView::updateView(bool forceUpdate) double appRotation = getViewObject()->Rotation.getValue(); double guiRotation = rotation(); - if (!TechDraw::DrawUtil::fpCompare(appRotation,guiRotation)) { + if (!TechDraw::DrawUtil::fpCompare(appRotation, guiRotation)) { rotateView(); } @@ -371,7 +369,7 @@ void QGIView::rotateView() //NOTE: QPainterPaths have to be rotated individually. This transform handles Rotation for everything else. //Scale is handled in GeometryObject for DVP & descendents //Objects not descended from DVP must setScale for themselves -//note that setTransform(,,rotation,,) is not the same as setRotation!!! +//note that setTransform(, ,rotation, ,) is not the same as setRotation!!! double rot = getViewObject()->Rotation.getValue(); QPointF centre = boundingRect().center(); setTransform(QTransform().translate(centre.x(), centre.y()).rotate(-rot).translate(-centre.x(), -centre.y())); @@ -410,8 +408,8 @@ void QGIView::setViewFeature(TechDraw::DrawView *obj) viewName = obj->getNameInDocument(); //mark the actual QGraphicsItem so we can check what's in the scene later - setData(0,QString::fromUtf8("QGIV")); - setData(1,QString::fromUtf8(obj->getNameInDocument())); + setData(0, QString::fromUtf8("QGIV")); + setData(1, QString::fromUtf8(obj->getNameInDocument())); } void QGIView::toggleCache(bool state) @@ -467,7 +465,7 @@ void QGIView::drawCaption() void QGIView::drawBorder() { -// Base::Console().Message("QGIV::drawBorder() - %s\n",getViewName()); +// Base::Console().Message("QGIV::drawBorder() - %s\n", getViewName()); auto feat = getViewObject(); if (!feat) return; @@ -525,15 +523,15 @@ void QGIView::drawBorder() if (feat->isLocked() && feat->showLock()) { m_lock->setZValue(ZVALUE::LOCK); - m_lock->setPos(lockX,lockY); + m_lock->setPos(lockX, lockY); m_lock->show(); } else { m_lock->hide(); } prepareGeometryChange(); - m_border->setRect(frameArea.adjusted(-2,-2,2,2)); - m_border->setPos(0.,0.); + m_border->setRect(frameArea.adjusted(-2, -2, 2,2)); + m_border->setPos(0., 0.); m_label->show(); if (getFrameState()) { @@ -578,7 +576,7 @@ QRectF QGIView::customChildrenBoundingRect() const ((*it)->type() != labelItemType) && ((*it)->type() != weldingSymbolItemType) && ((*it)->type() != captionItemType) ) { - QRectF childRect = mapFromItem(*it,(*it)->boundingRect()).boundingRect(); + QRectF childRect = mapFromItem(*it, (*it)->boundingRect()).boundingRect(); result = result.united(childRect); //result = result.united((*it)->boundingRect()); } @@ -588,7 +586,7 @@ QRectF QGIView::customChildrenBoundingRect() const QRectF QGIView::boundingRect() const { - return m_border->rect().adjusted(-2.,-2.,2.,2.); //allow for border line width //TODO: fiddle brect if border off? + return m_border->rect().adjusted(-2., -2., 2., 2.); //allow for border line width //TODO: fiddle brect if border off? } QGIView* QGIView::getQGIVByName(std::string name) @@ -617,18 +615,18 @@ Gui::ViewProvider* QGIView::getViewProvider(App::DocumentObject* obj) return nullptr; } -QGVPage* QGIView::getQGVPage(TechDraw::DrawView* dv) +QGVPage* QGIView::getQGVPage(TechDraw::DrawView* dView) { - ViewProviderPage* vpp = getViewProviderPage(dv); + ViewProviderPage* vpp = getViewProviderPage(dView); if (!vpp) { return vpp->getQGVPage(); } return nullptr; } -QGSPage* QGIView::getQGSPage(TechDraw::DrawView* dv) +QGSPage* QGIView::getQGSPage(TechDraw::DrawView* dView) { - ViewProviderPage* vpp = getViewProviderPage(dv); + ViewProviderPage* vpp = getViewProviderPage(dView); if (vpp) { return vpp->getQGSPage(); } @@ -647,12 +645,12 @@ MDIViewPage* QGIView::getMDIViewPage() const return nullptr; } -ViewProviderPage* QGIView::getViewProviderPage(TechDraw::DrawView* dv) +ViewProviderPage* QGIView::getViewProviderPage(TechDraw::DrawView* dView) { - if (!dv) { + if (!dView) { return nullptr; } - TechDraw::DrawPage* page = dv->findParentPage(); + TechDraw::DrawPage* page = dView->findParentPage(); if (!page) { return nullptr; } @@ -676,7 +674,7 @@ void QGIView::removeChild(QGIView* child) bool QGIView::getFrameState() { -// Base::Console().Message("QGIV::getFrameState() - %s\n",getViewName()); +// Base::Console().Message("QGIV::getFrameState() - %s\n", getViewName()); bool result = true; TechDraw::DrawView* dv = getViewObject(); if (dv) { @@ -693,17 +691,22 @@ bool QGIView::getFrameState() return result; } +void QGIView::hideFrame() +{ + m_border->hide(); + m_label->hide(); +} + void QGIView::addArbitraryItem(QGraphicsItem* qgi) { if (qgi) { -// m_randomItems.push_back(qgi); +// m_randomItems.push_back(qgi); addToGroup(qgi); qgi->show(); } } -//TODO: change name to prefNormalColor() -QColor QGIView::getNormalColor() +QColor QGIView::prefNormalColor() { return PreferencesGui::normalQColor(); } @@ -755,16 +758,16 @@ int QGIView::calculateFontPixelWidth(const QFont &font) const double QGIView::DefaultFontSizeInMM = 5.0; -void QGIView::dumpRect(const char* text, QRectF r) { - Base::Console().Message("DUMP - %s - rect: (%.3f,%.3f) x (%.3f,%.3f)\n",text, - r.left(),r.top(),r.right(),r.bottom()); +void QGIView::dumpRect(const char* text, QRectF rect) { + Base::Console().Message("DUMP - %s - rect: (%.3f, %.3f) x (%.3f, %.3f)\n", text, + rect.left(), rect.top(), rect.right(), rect.bottom()); } -void QGIView::makeMark(double x, double y, QColor c) +void QGIView::makeMark(double xPos, double yPos, QColor c) { QGIVertex* vItem = new QGIVertex(-1); vItem->setParentItem(this); - vItem->setPos(x,y); + vItem->setPos(xPos, yPos); vItem->setWidth(2.0); vItem->setRadius(20.0); vItem->setNormalColor(c); @@ -773,14 +776,14 @@ void QGIView::makeMark(double x, double y, QColor c) vItem->setZValue(ZVALUE::VERTEX); } -void QGIView::makeMark(Base::Vector3d v, QColor c) +void QGIView::makeMark(Base::Vector3d pos, QColor color) { - makeMark(v.x,v.y, c); + makeMark(pos.x, pos.y, color); } -void QGIView::makeMark(QPointF v, QColor c) +void QGIView::makeMark(QPointF pos, QColor color) { - makeMark(v.x(),v.y(), c); + makeMark(pos.x(), pos.y(), color); } #include diff --git a/src/Mod/TechDraw/Gui/QGIView.h b/src/Mod/TechDraw/Gui/QGIView.h index 49d68f59ab..cb238e2ea7 100644 --- a/src/Mod/TechDraw/Gui/QGIView.h +++ b/src/Mod/TechDraw/Gui/QGIView.h @@ -77,7 +77,7 @@ class TechDrawGuiExport QGIView : public QObject, public QGraphicsItemGroup Q_OBJECT public: QGIView(); - ~QGIView() override; + ~QGIView(); enum {Type = QGraphicsItem::UserType + 101}; int type() const override { return Type;} @@ -94,6 +94,8 @@ public: double getScale(); + void hideFrame(); //used by derived classes that don't display a frame + virtual bool getFrameState(); virtual void toggleCache(bool state); virtual void updateView(bool update = false); @@ -101,41 +103,43 @@ public: virtual void isVisible(bool state); virtual bool isVisible(); - virtual void setGroupSelection(bool b); + virtual void setGroupSelection(bool isSelected); virtual void draw(); virtual void drawCaption(); virtual void rotateView(); - void makeMark(double x, double y, QColor c = Qt::red); - void makeMark(Base::Vector3d v, QColor c = Qt::red); - void makeMark(QPointF p, QColor c = Qt::red); + void makeMark(double xPos, double yPos, QColor color = Qt::red); + void makeMark(Base::Vector3d pos, QColor color = Qt::red); + void makeMark(QPointF pos, QColor color = Qt::red); /** Methods to ensure that Y-Coordinates are orientated correctly. * @{ */ - void setPosition(qreal x, qreal y); + void setPosition(qreal xPos, qreal yPos); inline qreal getY() { return y() * -1; } - bool isInnerView() { return m_innerView; } + bool isInnerView() const { return m_innerView; } void isInnerView(bool state) { m_innerView = state; } double getYInClip(double y); - /** @} */ QGIViewClip* getClipGroup(); void alignTo(QGraphicsItem*, const QString &alignment); - void setLocked(bool b) { m_locked = b; } + void setLocked(bool isLocked) { m_locked = isLocked; } + + QColor prefNormalColor(); //preference + QColor getNormalColor() { return m_colNormal; } //current setting + void setNormalColor(QColor color) { m_colNormal = color; } + QColor getPreColor(); //preference + QColor getSelectColor(); //preference + QColor getCurrentColor() { return m_colCurrent; } + void setCurrentColor(QColor color) {m_colCurrent = color; } + QColor getSettingColor() { return m_colSetting; } + void setSettingColor(QColor color) { m_colSetting = color; } - virtual QColor getNormalColor(); //preference - virtual QColor getPreColor(); //preference - virtual QColor getSelectColor(); //preference - virtual QColor getCurrentColor() { return m_colCurrent; } - virtual QColor getSettingColor() { return m_colSetting; } - virtual void setSettingColor(QColor c) { m_colSetting = c; } - static Gui::ViewProvider* getViewProvider(App::DocumentObject* obj); - static ViewProviderPage* getViewProviderPage(TechDraw::DrawView* dv); - static QGVPage* getQGVPage(TechDraw::DrawView* dv); - static QGSPage* getQGSPage(TechDraw::DrawView* dv); + static ViewProviderPage* getViewProviderPage(TechDraw::DrawView* dView); + static QGVPage* getQGVPage(TechDraw::DrawView* dView); + static QGSPage* getQGSPage(TechDraw::DrawView* dView); static int calculateFontPixelSize(double sizeInMillimetres); static int calculateFontPixelWidth(const QFont &font); static const double DefaultFontSizeInMM; @@ -143,7 +147,8 @@ public: static QString getPrefFont(); static double getPrefFontSize(); static double getDimFontSize(); - + QFont getFont() { return m_font; }; + void setFont(QFont font) { m_font = font; } virtual void removeChild(QGIView* child); virtual void addArbitraryItem(QGraphicsItem* qgi); @@ -166,20 +171,15 @@ protected: void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; virtual QRectF customChildrenBoundingRect() const; - void dumpRect(const char* text, QRectF r); - -/* QString getPrefFont(void);*/ -/* double getPrefFontSize(void);*/ -/* double getDimFontSize(void);*/ + void dumpRect(const char* text, QRectF rect); Base::Reference getParmGroupCol(); +private: TechDraw::DrawView *viewObj; std::string viewName; QHash alignHash; - //std::string alignMode; - //QGIView* alignAnchor; bool m_locked; bool m_innerView; //View is inside another View diff --git a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp index 471b1826c6..1fbb55413c 100644 --- a/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewAnnotation.cpp @@ -74,9 +74,9 @@ QGIViewAnnotation::QGIViewAnnotation() m_textItem->setTextInteractionFlags(Qt::NoTextInteraction); //To allow on screen editing of text: //m_textItem->setTextInteractionFlags(Qt::TextEditorInteraction); //this works - //QObject::connect(QGraphicsTextItem::document(), SIGNAL(contentsChanged()),m_textItem, SLOT(updateText())); //not tested + //QObject::connect(QGraphicsTextItem::document(), SIGNAL(contentsChanged()), m_textItem, SLOT(updateText())); //not tested addToGroup(m_textItem); - m_textItem->setPos(0.,0.); + m_textItem->setPos(0., 0.); } @@ -144,7 +144,7 @@ void QGIViewAnnotation::drawAnnotation() } else if (viewAnno->TextStyle.isValue("Bold-Italic")) { ss << "font-weight:bold; font-style:italic; "; } else { - Base::Console().Warning("%s has invalid TextStyle\n",viewAnno->getNameInDocument()); + Base::Console().Warning("%s has invalid TextStyle\n", viewAnno->getNameInDocument()); ss << "font-weight:normal; font-style:normal; "; } ss << "line-height:" << viewAnno->LineSpace.getValue() << "%; "; @@ -166,7 +166,7 @@ void QGIViewAnnotation::drawAnnotation() m_textItem->setTextWidth(Rez::guiX(viewAnno->MaxWidth.getValue())); QString qs = QString::fromUtf8(ss.str().c_str()); m_textItem->setHtml(qs); - m_textItem->centerAt(0.,0.); + m_textItem->centerAt(0., 0.); } void QGIViewAnnotation::rotateView() diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp index aefaeda13e..cc5e1bfa98 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.cpp @@ -59,7 +59,6 @@ #include #include #include -//#include #include "Rez.h" #include "ZVALUE.h" @@ -68,12 +67,7 @@ #include "QGIDimLines.h" #include "QGIViewBalloon.h" #include "ViewProviderBalloon.h" -#include "DrawGuiUtil.h" -#include "QGIViewPart.h" #include "ViewProviderViewPart.h" -#include "QGIViewDimension.h" -#include "QGVPage.h" -#include "MDIViewPage.h" //TODO: hide the Qt coord system (+y down). @@ -140,7 +134,7 @@ void QGIBalloonLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) Q_EMIT dragFinished(); } } - m_ctrl = false; + m_ctrl = false; m_drag = false; QGraphicsItem::mouseReleaseEvent(event); } @@ -208,53 +202,53 @@ void QGIBalloonLabel::paint(QPainter *painter, const QStyleOptionGraphicsItem *o void QGIBalloonLabel::setPosFromCenter(const double &xCenter, const double &yCenter) { - //set label's Qt position(top,left) given boundingRect center point + //set label's Qt position(top, left) given boundingRect center point setPos(xCenter - m_labelText->boundingRect().width() / 2., yCenter - m_labelText->boundingRect().height() / 2.); } void QGIBalloonLabel::setLabelCenter() { - //save label's bRect center (posX,posY) given Qt position (top,left) + //save label's bRect center (posX, posY) given Qt position (top, left) posX = x() + m_labelText->boundingRect().width() / 2.; posY = y() + m_labelText->boundingRect().height() / 2.; } -void QGIBalloonLabel::setFont(QFont f) +void QGIBalloonLabel::setFont(QFont font) { - m_labelText->setFont(f); + m_labelText->setFont(font); } -void QGIBalloonLabel::setDimString(QString t) +void QGIBalloonLabel::setDimString(QString text) { prepareGeometryChange(); - m_labelText->setPlainText(t); -} + m_labelText->setPlainText(text); +} -void QGIBalloonLabel::setDimString(QString t, qreal maxWidth) +void QGIBalloonLabel::setDimString(QString text, qreal maxWidth) { prepareGeometryChange(); - m_labelText->setPlainText(t); + m_labelText->setPlainText(text); m_labelText->setTextWidth(maxWidth); } -void QGIBalloonLabel::setPrettySel(void) +void QGIBalloonLabel::setPrettySel() { m_labelText->setPrettySel(); } -void QGIBalloonLabel::setPrettyPre(void) +void QGIBalloonLabel::setPrettyPre() { m_labelText->setPrettyPre(); } -void QGIBalloonLabel::setPrettyNormal(void) +void QGIBalloonLabel::setPrettyNormal() { m_labelText->setPrettyNormal(); } -void QGIBalloonLabel::setColor(QColor c) +void QGIBalloonLabel::setColor(QColor color) { - m_colNormal = c; + m_colNormal = color; m_labelText->setColor(m_colNormal); } @@ -274,28 +268,28 @@ QGIViewBalloon::QGIViewBalloon() : setCacheMode(QGraphicsItem::NoCache); balloonLabel = new QGIBalloonLabel(); - balloonLabel->parent = this; + balloonLabel->setQBalloon(this); addToGroup(balloonLabel); - balloonLabel->setColor(getNormalColor()); + balloonLabel->setColor(prefNormalColor()); balloonLabel->setPrettyNormal(); balloonLines = new QGIDimLines(); addToGroup(balloonLines); - balloonLines->setNormalColor(getNormalColor()); + balloonLines->setNormalColor(prefNormalColor()); balloonLines->setPrettyNormal(); balloonShape = new QGIDimLines(); addToGroup(balloonShape); - balloonShape->setNormalColor(getNormalColor()); + balloonShape->setNormalColor(prefNormalColor()); balloonShape->setFill(Qt::white, Qt::SolidPattern); balloonShape->setFillOverride(true); balloonShape->setPrettyNormal(); - + arrow = new QGIArrow(); addToGroup(arrow); - arrow->setNormalColor(getNormalColor()); - arrow->setFillColor(getNormalColor()); + arrow->setNormalColor(prefNormalColor()); + arrow->setFillColor(prefNormalColor()); arrow->setPrettyNormal(); arrow->setStyle(prefDefaultArrow()); @@ -344,13 +338,13 @@ QVariant QGIViewBalloon::itemChange(GraphicsItemChange change, const QVariant &v } //Set selection state for this and it's children -void QGIViewBalloon::setGroupSelection(bool b) +void QGIViewBalloon::setGroupSelection(bool isSelected) { -// Base::Console().Message("QGIVB::setGroupSelection(%d)\n",b); - setSelected(b); - balloonLabel->setSelected(b); - balloonLines->setSelected(b); - arrow->setSelected(b); +// Base::Console().Message("QGIVB::setGroupSelection(%d)\n", b); + setSelected(isSelected); + balloonLabel->setSelected(isSelected); + balloonLines->setSelected(isSelected); + arrow->setSelected(isSelected); } void QGIViewBalloon::select(bool state) @@ -366,31 +360,32 @@ void QGIViewBalloon::hover(bool state) draw(); } -void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloon) +void QGIViewBalloon::setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat) { // Base::Console().Message("QGIVB::setViewPartFeature()\n"); - if (!balloon) + if (!balloonFeat) return; - setViewFeature(static_cast(balloon)); + setViewFeature(static_cast(balloonFeat)); + dvBalloon = balloonFeat; DrawView* balloonParent = nullptr; double scale = 1.0; - App::DocumentObject* docObj = balloon->SourceView.getValue(); + App::DocumentObject* docObj = balloonFeat->SourceView.getValue(); if (docObj) { balloonParent = dynamic_cast(docObj); if (balloonParent) scale = balloonParent->getScale(); } - float x = Rez::guiX(balloon->X.getValue() * scale) ; - float y = Rez::guiX(-balloon->Y.getValue() * scale); + float x = Rez::guiX(balloonFeat->X.getValue() * scale) ; + float y = Rez::guiX(-balloonFeat->Y.getValue() * scale); - balloonLabel->setColor(getNormalColor()); + balloonLabel->setColor(prefNormalColor()); balloonLabel->setPosFromCenter(x, y); - QString labelText = QString::fromUtf8(balloon->Text.getStrValue().data()); - balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue())); + QString labelText = QString::fromUtf8(balloonFeat->Text.getStrValue().data()); + balloonLabel->setDimString(labelText, Rez::guiX(balloonFeat->TextWrapLen.getValue())); updateBalloon(); @@ -448,17 +443,19 @@ void QGIViewBalloon::updateBalloon(bool obtuse) balloonLabel->setFont(font); QString labelText = QString::fromUtf8(balloon->Text.getStrValue().data()); - balloonLabel->verticalSep = false; - balloonLabel->seps.clear(); + balloonLabel->setVerticalSep(false); + balloonLabel->setSeps(std::vector()); if (strcmp(balloon->BubbleShape.getValueAsString(), "Rectangle") == 0) { + std::vector newSeps; while (labelText.contains(QString::fromUtf8("|"))) { int pos = labelText.indexOf(QString::fromUtf8("|")); labelText.replace(pos, 1, QString::fromUtf8(" ")); QFontMetrics fm(balloonLabel->getFont()); - balloonLabel->seps.push_back(Gui::QtTools::horizontalAdvance(fm, labelText.left(pos + 2))); - balloonLabel->verticalSep = true; + newSeps.push_back(Gui::QtTools::horizontalAdvance(fm, labelText.left(pos + 2))); + balloonLabel->setVerticalSep(true); } + balloonLabel->setSeps(newSeps); } balloonLabel->setDimString(labelText, Rez::guiX(balloon->TextWrapLen.getValue())); @@ -490,7 +487,7 @@ void QGIViewBalloon::balloonLabelDragged(bool ctrl) // redraw the balloon at the new position // note that we don't store the new position to the X/Y properties // since the dragging is not yet finished - drawBalloon(true); + drawBalloon(true); } void QGIViewBalloon::balloonLabelDragFinished() @@ -506,7 +503,7 @@ void QGIViewBalloon::balloonLabelDragFinished() if (balloonParent) scale = balloonParent->getScale(); - //set feature position (x,y) from graphic position + //set feature position (x, y) from graphic position double x = Rez::appX(balloonLabel->X() / scale), y = Rez::appX(balloonLabel->Y() / scale); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Drag Balloon")); @@ -522,7 +519,7 @@ void QGIViewBalloon::balloonLabelDragFinished() Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.OriginY = %f", dvb->getNameInDocument(), newOrg.y); } - + Gui::Command::commitCommand(); m_dragInProgress = false; @@ -543,12 +540,12 @@ void QGIViewBalloon::placeBalloon(QPointF pos) if (!balloonParent) { return; } - + auto featPage = balloonParent->findParentPage(); if (!featPage) { return; } - + auto vp = static_cast(getViewProvider(getViewObject())); if (!vp) { return; @@ -562,7 +559,7 @@ void QGIViewBalloon::placeBalloon(QPointF pos) qgivParent = partVP->getQView(); if (qgivParent) { //tip position is mouse release pos in parentView coords ==> OriginX, OriginY - //bubble pos is some arbitrary shift from tip position ==> X,Y + //bubble pos is some arbitrary shift from tip position ==> X, Y viewPos = qgivParent->mapFromScene(pos); balloon->OriginX.setValue(Rez::appX(viewPos.x()) / balloonParent->getScale()); balloon->OriginY.setValue(-Rez::appX(viewPos.y()) / balloonParent->getScale()); @@ -574,7 +571,7 @@ void QGIViewBalloon::placeBalloon(QPointF pos) int idx = featPage->getNextBalloonIndex(); QString labelText = QString::number(idx); balloon->Text.setValue(std::to_string(idx).c_str()); - + QFont font = balloonLabel->getFont(); font.setPixelSize(calculateFontPixelSize(vp->Fontsize.getValue())); font.setFamily(QString::fromUtf8(vp->Font.getValue())); @@ -676,7 +673,7 @@ void QGIViewBalloon::drawBalloon(bool dragged) double balloonRadius = sqrt(pow((textHeight / 2.0), 2) + pow((textWidth / 2.0), 2)); balloonRadius = balloonRadius * scale; balloonPath.moveTo(lblCenter.x, lblCenter.y); - balloonPath.addEllipse(lblCenter.x - balloonRadius,lblCenter.y - balloonRadius, balloonRadius * 2, balloonRadius * 2); + balloonPath.addEllipse(lblCenter.x - balloonRadius, lblCenter.y - balloonRadius, balloonRadius * 2, balloonRadius * 2); offsetLR = balloonRadius; } else if (strcmp(balloonType, "None") == 0) { balloonPath = QPainterPath(); @@ -684,11 +681,11 @@ void QGIViewBalloon::drawBalloon(bool dragged) } else if (strcmp(balloonType, "Rectangle") == 0) { //Add some room textHeight = (textHeight * scale) + Rez::guiX(1.0); - // we add some textWidth later because we first need to handle the text separators - if (balloonLabel->verticalSep) { - for (std::vector::iterator it = balloonLabel->seps.begin() ; it != balloonLabel->seps.end(); ++it) { - balloonPath.moveTo(lblCenter.x - (textWidth / 2.0) + *it, lblCenter.y - (textHeight / 2.0)); - balloonPath.lineTo(lblCenter.x - (textWidth / 2.0) + *it, lblCenter.y + (textHeight / 2.0)); + // we add some textWidth later because we first need to handle the text separators + if (balloonLabel->getVerticalSep()) { + for (auto& sep : balloonLabel->getSeps()) { + balloonPath.moveTo(lblCenter.x - (textWidth / 2.0) + sep, lblCenter.y - (textHeight / 2.0)); + balloonPath.lineTo(lblCenter.x - (textWidth / 2.0) + sep, lblCenter.y + (textHeight / 2.0)); } } textWidth = (textWidth * scale) + Rez::guiX(2.0); @@ -910,21 +907,20 @@ void QGIViewBalloon::setPens(void) arrow->setWidth(m_lineWidth); } -QColor QGIViewBalloon::getNormalColor() +QColor QGIViewBalloon::prefNormalColor() { - m_colNormal = PreferencesGui::dimQColor(); + setNormalColor(PreferencesGui::dimQColor()); - auto balloon( dynamic_cast(getViewObject()) ); - if(!balloon) - return m_colNormal; - - auto vp = static_cast(getViewProvider(getViewObject())); - if (!vp) { - return m_colNormal; + ViewProviderBalloon* vpBalloon = nullptr; + Gui::ViewProvider* vp = getViewProvider(getBalloonFeat()); + if (vp) { + vpBalloon = dynamic_cast(vp); + if (vpBalloon) { + App::Color fcColor = vpBalloon->Color.getValue(); + setNormalColor(fcColor.asValue()); + } } - - m_colNormal = vp->Color.getValue().asValue(); - return m_colNormal; + return getNormalColor(); } int QGIViewBalloon::prefDefaultArrow() const diff --git a/src/Mod/TechDraw/Gui/QGIViewBalloon.h b/src/Mod/TechDraw/Gui/QGIViewBalloon.h index 36c16fd69f..fd97846bb9 100644 --- a/src/Mod/TechDraw/Gui/QGIViewBalloon.h +++ b/src/Mod/TechDraw/Gui/QGIViewBalloon.h @@ -61,7 +61,7 @@ Q_OBJECT public: QGIBalloonLabel(); - ~QGIBalloonLabel() override = default; + ~QGIBalloonLabel() = default; enum {Type = QGraphicsItem::UserType + 141}; int type() const override { return Type;} @@ -75,28 +75,29 @@ public: void setPosFromCenter(const double &xCenter, const double &yCenter); double X() const { return posX; } double Y() const { return posY; } //minus posY? - - void setFont(QFont f); + + void setFont(QFont font); QFont getFont() { return m_labelText->font(); } - void setDimString(QString t); - void setDimString(QString t, qreal maxWidth); + void setDimString(QString text); + void setDimString(QString text, qreal maxWidth); void setPrettySel(); void setPrettyPre(); void setPrettyNormal(); - void setColor(QColor c); + void setColor(QColor color); + + void setQBalloon(QGIViewBalloon* qBalloon) { parent = qBalloon;} - bool verticalSep; - std::vector seps; QGCustomText* getDimText() { return m_labelText; } + void setDimText(QGCustomText* newText) { m_labelText = newText; } - - bool hasHover; - - QGIViewBalloon *parent; + bool getVerticalSep() const { return verticalSep; } + void setVerticalSep(bool sep) { verticalSep = sep; } + std::vector getSeps() const { return seps; } + void setSeps(std::vector newSeps) { seps = newSeps; } Q_SIGNALS: - void dragging(bool); + void dragging(bool state); void hover(bool state); void selected(bool state); void dragFinished(); @@ -108,6 +109,13 @@ protected: void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; +private: + bool hasHover; + + QGIViewBalloon *parent; + bool verticalSep; + std::vector seps; + QGCustomText* m_labelText; QColor m_colNormal; @@ -115,8 +123,6 @@ protected: double posY; bool m_ctrl; bool m_drag; - -private: }; //******************************************************************* @@ -129,9 +135,9 @@ public: enum {Type = QGraphicsItem::UserType + 140}; explicit QGIViewBalloon(); - ~QGIViewBalloon() override = default; + ~QGIViewBalloon() = default; - void setViewPartFeature(TechDraw::DrawViewBalloon *obj); + void setViewPartFeature(TechDraw::DrawViewBalloon *balloonFeat); int type() const override { return Type;} void drawBorder() override; @@ -142,18 +148,17 @@ public: QString getLabelText(); void placeBalloon(QPointF pos); - TechDraw::DrawViewBalloon *dvBalloon; void setPrettyPre(); void setPrettySel(); void setPrettyNormal(); - void setGroupSelection(bool b) override; + void setGroupSelection(bool isSelected) override; virtual QGIBalloonLabel* getBalloonLabel() { return balloonLabel; } - QColor getNormalColor() override; + QColor prefNormalColor(); int prefDefaultArrow() const; bool prefOrthoPyramid() const; - + TechDraw::DrawViewBalloon* getBalloonFeat() { return dvBalloon; } public Q_SLOTS: void balloonLabelDragged(bool ctrl); @@ -170,8 +175,11 @@ protected: virtual void setSvgPens(); virtual void setPens(); QString getPrecision(); + void parentViewMousePressed(QGIView *view, QPointF pos); + TechDraw::DrawView* getSourceView() const; -protected: +private: + TechDraw::DrawViewBalloon *dvBalloon; bool hasHover; QGIBalloonLabel* balloonLabel; QGIDimLines* balloonLines; @@ -179,16 +187,12 @@ protected: QGIArrow* arrow; double m_lineWidth; bool m_obtuse; - void parentViewMousePressed(QGIView *view, QPointF pos); QGIView *parent; //used to create edit dialog - TechDraw::DrawView* getSourceView() const; bool m_dragInProgress; bool m_originDragged = false; bool m_ctrl; Base::Vector3d m_saveOffset; - - }; } // namespace diff --git a/src/Mod/TechDraw/Gui/QGIViewClip.cpp b/src/Mod/TechDraw/Gui/QGIViewClip.cpp index 7f96c5f01d..a40bdb3cae 100644 --- a/src/Mod/TechDraw/Gui/QGIViewClip.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewClip.cpp @@ -52,13 +52,13 @@ QGIViewClip::QGIViewClip() m_cliparea = new QGCustomClip(); addToGroup(m_cliparea); - m_cliparea->setPos(0.,0.); - m_cliparea->setRect(0.,0.,Rez::guiX(5.),Rez::guiX(5.)); + m_cliparea->setPos(0., 0.); + m_cliparea->setRect(0., 0., Rez::guiX(5.), Rez::guiX(5.)); m_frame = new QGCustomRect(); addToGroup(m_frame); - m_frame->setPos(0.,0.); - m_frame->setRect(0.,0.,Rez::guiX(5.),Rez::guiX(5.)); + m_frame->setPos(0., 0.); + m_frame->setRect(0., 0., Rez::guiX(5.), Rez::guiX(5.)); } void QGIViewClip::updateView(bool update) @@ -102,9 +102,9 @@ void QGIViewClip::drawClip() prepareGeometryChange(); double h = viewClip->Height.getValue(); double w = viewClip->Width.getValue(); - QRectF r = QRectF(-Rez::guiX(w)/2.0,-Rez::guiX(h)/2.0,Rez::guiX(w),Rez::guiX(h)); - m_frame->setRect(r); // (-50,-50) -> (50,50) - m_frame->setPos(0.,0.); + QRectF r = QRectF(-Rez::guiX(w)/2.0, -Rez::guiX(h)/2.0, Rez::guiX(w), Rez::guiX(h)); + m_frame->setRect(r); // (-50, -50) -> (50, 50) + m_frame->setPos(0., 0.); if (viewClip->ShowFrame.getValue()) { m_frame->show(); } else { @@ -113,10 +113,10 @@ void QGIViewClip::drawClip() //probably a slicker way to do this? QPointF midFrame = m_frame->boundingRect().center(); - QPointF midMapped = mapFromItem(m_frame,midFrame); - QPointF clipOrigin = mapToItem(m_cliparea,midMapped); + QPointF midMapped = mapFromItem(m_frame, midFrame); + QPointF clipOrigin = mapToItem(m_cliparea, midMapped); - m_cliparea->setRect(r.adjusted(-1,-1,1,1)); + m_cliparea->setRect(r.adjusted(-1, -1, 1,1)); std::vector childNames = viewClip->getChildViewNames(); //for all child Views in Clip, add the graphics representation of the View to the Clip group @@ -140,7 +140,7 @@ void QGIViewClip::drawClip() qgiv->show(); } } else { - Base::Console().Warning("Logic error? - drawClip() - qgiv for %s not found\n",(*it).c_str()); //gview for feature !exist + Base::Console().Warning("Logic error? - drawClip() - qgiv for %s not found\n", (*it).c_str()); //gview for feature !exist } } @@ -151,7 +151,7 @@ void QGIViewClip::drawClip() QGIView* qv = dynamic_cast((*it)); if (qv) { std::string qvName = std::string(qv->getViewName()); - if (std::find(childNames.begin(),childNames.end(),qvName) == childNames.end()) { + if (std::find(childNames.begin(), childNames.end(), qvName) == childNames.end()) { m_cliparea->removeFromGroup(qv); removeFromGroup(qv); qv->isInnerView(false); diff --git a/src/Mod/TechDraw/Gui/QGIViewCollection.h b/src/Mod/TechDraw/Gui/QGIViewCollection.h index 32e54becd6..3628e42c0e 100644 --- a/src/Mod/TechDraw/Gui/QGIViewCollection.h +++ b/src/Mod/TechDraw/Gui/QGIViewCollection.h @@ -20,8 +20,8 @@ * * ***************************************************************************/ -#ifndef _DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H -#define _DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H +#ifndef DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H +#define DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H #include @@ -47,4 +47,4 @@ public: } // namespace MDIViewPageGui -#endif // _DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H +#endif // DRAWINGGUI_QGRAPHICSITEMVIEWCOLLECTION_H diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index d2d307982c..38f0eed144 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -28,23 +28,22 @@ #include #ifndef _PreComp_ - #include - #include - # include - # include - # include - # include - # include - - # include - # include - # include - # include - # include - # include - # include - # include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif #include @@ -62,29 +61,22 @@ #include #include -#include "Rez.h" #include "ZVALUE.h" + #include "PreferencesGui.h" - -#include "QGCustomLabel.h" -#include "QGCustomBorder.h" -#include "QGCustomText.h" -#include "QGICaption.h" -#include "QGCustomImage.h" - #include "QGIArrow.h" #include "QGIDimLines.h" -#include "QGIViewDimension.h" -#include "ViewProviderDimension.h" -#include "DrawGuiUtil.h" #include "QGIVertex.h" +#include "ViewProviderDimension.h" + +#include "QGIViewDimension.h" #define NORMAL 0 #define PRE 1 #define SEL 2 -//TODO: hide the Qt coord system (+y down). +//TODO: hide the Qt coord system (+y down). using namespace TechDraw; using namespace TechDrawGui; @@ -261,7 +253,7 @@ void QGIDatumLabel::setPosFromCenter(const double &xCenter, const double &yCente if (!dim) return; - //set label's Qt position(top,left) given boundingRect center point + //set label's Qt position(top, left) given boundingRect center point setPos(xCenter - m_dimText->boundingRect().width() / 2., yCenter - m_dimText->boundingRect().height() / 2.); QString uText = m_unitText->toPlainText(); @@ -306,34 +298,34 @@ void QGIDatumLabel::setPosFromCenter(const double &xCenter, const double &yCente void QGIDatumLabel::setLabelCenter() { - //save label's bRect center (posX,posY) given Qt position (top,left) + //save label's bRect center (posX, posY) given Qt position (top, left) posX = x() + m_dimText->boundingRect().width() / 2.; posY = y() + m_dimText->boundingRect().height() / 2.; } -void QGIDatumLabel::setFont(QFont f) +void QGIDatumLabel::setFont(QFont font) { prepareGeometryChange(); - m_dimText->setFont(f); - m_unitText->setFont(f); - QFont tFont(f); - double fontSize = f.pixelSize(); + m_dimText->setFont(font); + m_unitText->setFont(font); + QFont tFont(font); + double fontSize = font.pixelSize(); double tolAdj = getTolAdjust(); tFont.setPixelSize((int) (fontSize * tolAdj)); m_tolTextOver->setFont(tFont); m_tolTextUnder->setFont(tFont); } -void QGIDatumLabel::setDimString(QString t) +void QGIDatumLabel::setDimString(QString text) { prepareGeometryChange(); - m_dimText->setPlainText(t); -} + m_dimText->setPlainText(text); +} -void QGIDatumLabel::setDimString(QString t, qreal maxWidth) +void QGIDatumLabel::setDimString(QString text, qreal maxWidth) { prepareGeometryChange(); - m_dimText->setPlainText(t); + m_dimText->setPlainText(text); m_dimText->setTextWidth(maxWidth); } @@ -388,18 +380,18 @@ void QGIDatumLabel::setToleranceString() } return; -} +} -void QGIDatumLabel::setUnitString(QString t) +void QGIDatumLabel::setUnitString(QString text) { prepareGeometryChange(); - if (t.isEmpty()) { + if (text.isEmpty()) { m_unitText->hide(); } else { - m_unitText->setPlainText(t); + m_unitText->setPlainText(text); m_unitText->show(); } -} +} int QGIDatumLabel::getPrecision() @@ -458,10 +450,10 @@ void QGIDatumLabel::setPrettyNormal() Q_EMIT setPretty(NORMAL); } -void QGIDatumLabel::setColor(QColor c) +void QGIDatumLabel::setColor(QColor color) { // Base::Console().Message("QGIDL::setColor(%s)\n", qPrintable(c.name())); - m_colNormal = c; + m_colNormal = color; m_dimText->setColor(m_colNormal); m_tolTextOver->setColor(m_colNormal); m_tolTextUnder->setColor(m_colNormal); @@ -481,7 +473,7 @@ QGIViewDimension::QGIViewDimension() : setCacheMode(QGraphicsItem::NoCache); datumLabel = new QGIDatumLabel(); -// datumLabel->m_parent = this; //for dialog setup eventually + datumLabel->setQDim(this); addToGroup(datumLabel); @@ -523,8 +515,7 @@ QGIViewDimension::QGIViewDimension() : setZValue(ZVALUE::DIMENSION); //note: this won't paint dimensions over another View if it stacks //above this Dimension's parent view. need Layers? - m_border->hide(); - m_label->hide(); + hideFrame(); } QVariant QGIViewDimension::itemChange(GraphicsItemChange change, const QVariant &value) @@ -542,14 +533,14 @@ QVariant QGIViewDimension::itemChange(GraphicsItemChange change, const QVariant } //Set selection state for this and it's children -void QGIViewDimension::setGroupSelection(bool b) +void QGIViewDimension::setGroupSelection(bool isSelected) { -// Base::Console().Message("QGIVD::setGroupSelection(%d)\n",b); - setSelected(b); - datumLabel->setSelected(b); - dimLines->setSelected(b); - aHead1->setSelected(b); - aHead2->setSelected(b); +// Base::Console().Message("QGIVD::setGroupSelection(%d)\n", b); + setSelected(isSelected); + datumLabel->setSelected(isSelected); + dimLines->setSelected(isSelected); + aHead1->setSelected(isSelected); + aHead2->setSelected(isSelected); } void QGIViewDimension::select(bool state) @@ -573,6 +564,7 @@ void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj) return; setViewFeature(static_cast(obj)); + dvDimension = obj; // Set the QGIGroup Properties based on the DrawView float x = Rez::guiX(obj->X.getValue()); @@ -590,7 +582,7 @@ void QGIViewDimension::setViewPartFeature(TechDraw::DrawViewDimension *obj) void QGIViewDimension::setNormalColorAll() { QColor qc = prefNormalColor(); - datumLabel->setColor(qc); + datumLabel->setColor(qc); dimLines->setNormalColor(qc); aHead1->setNormalColor(qc); aHead1->setFillColor(qc); @@ -602,7 +594,7 @@ void QGIViewDimension::setNormalColorAll() //and so mouse events need to be ignored. Only the QGIDatumLabel mouse events are relevant. void QGIViewDimension::mousePressEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGIVD::mousePressEvent() - %s\n",getViewName()); +// Base::Console().Message("QGIVD::mousePressEvent() - %s\n", getViewName()); QGraphicsItem::mousePressEvent(event); } @@ -613,7 +605,7 @@ void QGIViewDimension::mouseMoveEvent(QGraphicsSceneMouseEvent * event) void QGIViewDimension::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { -// Base::Console().Message("QGIVDim::mouseReleaseEvent() - %s\n",getViewName()); +// Base::Console().Message("QGIVDim::mouseReleaseEvent() - %s\n", getViewName()); QGraphicsItem::mouseReleaseEvent(event); } @@ -633,7 +625,7 @@ void QGIViewDimension::updateView(bool update) dim->Y.isTouched()) { float x = Rez::guiX(dim->X.getValue()); float y = Rez::guiX(dim->Y.getValue()); - datumLabel->setPosFromCenter(x,-y); + datumLabel->setPosFromCenter(x, -y); updateDim(); } else if(vp->Fontsize.isTouched() || vp->Font.isTouched()) { @@ -656,7 +648,7 @@ void QGIViewDimension::updateDim() auto vp = static_cast(getViewProvider(getViewObject())); if (!vp) return; - + QString labelText= QString::fromUtf8(dim->getFormattedDimensionValue(1).c_str()); // pre value [unit] post if (dim->isMultiValueSchema()) labelText = QString::fromUtf8(dim->getFormattedDimensionValue(0).c_str()); //don't format multis @@ -669,7 +661,7 @@ void QGIViewDimension::updateDim() prepareGeometryChange(); datumLabel->setDimString(labelText); datumLabel->setToleranceString(); - datumLabel->setPosFromCenter(datumLabel->X(),datumLabel->Y()); + datumLabel->setPosFromCenter(datumLabel->X(), datumLabel->Y()); datumLabel->setFramed(dim->TheoreticalExact.getValue()); datumLabel->setLineWidth(m_lineWidth); @@ -691,8 +683,8 @@ void QGIViewDimension::datumLabelDragFinished() double x = Rez::appX(datumLabel->X()), y = Rez::appX(datumLabel->Y()); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Drag Dimension")); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.X = %f", dim->getNameInDocument(), x); - Gui::Command::doCommand(Gui::Command::Doc,"App.ActiveDocument.%s.Y = %f", dim->getNameInDocument(), -y); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.X = %f", dim->getNameInDocument(), x); + Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.%s.Y = %f", dim->getNameInDocument(), -y); Gui::Command::commitCommand(); } @@ -813,7 +805,7 @@ double QGIViewDimension::getAnglePlacementFactor(double testAngle, double endAng if (testAngle >= endAngle + startRotation) { return -1.0; } - + return 0.0; } @@ -952,7 +944,7 @@ double QGIViewDimension::computeLineStrikeFactor(const Base::BoundBox2d &labelRe if (drawMarking.size() < 2) { return 0.0; } - + std::vector intersectionPoints; unsigned int startIndex = 0; unsigned int currentIndex = 1; @@ -1112,7 +1104,7 @@ bool QGIViewDimension::constructDimensionLine(const Base::Vector2d &targetPoint, bool QGIViewDimension::constructDimensionArc(const Base::Vector2d &arcCenter, double arcRadius, double endAngle, double startRotation, double handednessFactor, double jointRotation, - const Base::BoundBox2d &labelRectangle, int arrowCount, int standardStyle, bool flipArrows, + const Base::BoundBox2d &labelRectangle, int arrowCount, int standardStyle, bool flipArrows, std::vector> &outputMarking) const { // The start rotation > 0 is not expected, the caller must handle this @@ -1140,7 +1132,7 @@ bool QGIViewDimension::constructDimensionArc(const Base::Vector2d &arcCenter, do } else if (standardStyle == ViewProviderDimension::STD_STYLE_ASME_INLINED) { std::vector intersectionPoints; - + DrawUtil::findCircleRectangleIntersections(arcCenter, arcRadius, labelRectangle, intersectionPoints); // We do not want to handle other cases than 2 intersection points - if so, act as if there were none @@ -1165,7 +1157,7 @@ bool QGIViewDimension::constructDimensionArc(const Base::Vector2d &arcCenter, do if (jointRotation + endDelta > 0.0) { // If label exceeds end angle ray, extend the dimension arc and flip arrows DrawUtil::intervalMarkCircular(outputMarking, endAngle, handednessFactor*(jointRotation + endDelta), true); - autoFlipArrows = true; + autoFlipArrows = true; } if (jointRotation - startDelta < startRotation) { @@ -1197,10 +1189,10 @@ bool QGIViewDimension::constructDimensionArc(const Base::Vector2d &arcCenter, do double tailDelta = arcRadius >= Precision::Confusion() ? getDefaultArrowTailLength()/arcRadius : M_PI_4; double placementFactor = flipArrows ? +1.0 : -1.0; - DrawUtil::intervalMarkCircular(outputMarking, endAngle, + DrawUtil::intervalMarkCircular(outputMarking, endAngle, placementFactor*handednessFactor*tailDelta, true); if (arrowCount > 1) { - DrawUtil::intervalMarkCircular(outputMarking, endAngle + handednessFactor*startRotation, + DrawUtil::intervalMarkCircular(outputMarking, endAngle + handednessFactor*startRotation, -placementFactor*handednessFactor*tailDelta, true); } @@ -1280,7 +1272,7 @@ void QGIViewDimension::drawMultiLine(QPainterPath &painterPath, const Base::Vect if (drawMarking.size() < 2) { return; } - + unsigned int startIndex = 0; unsigned int currentIndex = 1; while (currentIndex < drawMarking.size()) { @@ -1859,7 +1851,7 @@ void QGIViewDimension::drawRadiusExecutive(const Base::Vector2d ¢erPoint, co lineAngles[1], lineMarking); } - if (compareAngleStraightness(0.0, + if (compareAngleStraightness(0.0, jointPositions[0] > 0.0 ? DrawUtil::angleComposition(lineAngles[0], M_PI) : lineAngles[0], jointPositions[1] > 0.0 ? DrawUtil::angleComposition(lineAngles[1], M_PI) : lineAngles[1], strikeFactors[0], strikeFactors[1]) > 0) { @@ -1981,7 +1973,7 @@ void QGIViewDimension::drawRadiusExecutive(const Base::Vector2d ¢erPoint, co void QGIViewDimension::drawDistance(TechDraw::DrawViewDimension *dimension, ViewProviderDimension *viewProvider) const { Base::BoundBox2d labelRectangle(fromQtGui(mapRectFromItem(datumLabel, datumLabel->boundingRect()))); - + pointPair linePoints = dimension->getLinearPoints(); const char *dimensionType = dimension->Type.getValueAsString(); @@ -2101,7 +2093,7 @@ void QGIViewDimension::drawDiameter(TechDraw::DrawViewDimension *dimension, View strikeFactors[1] = computeLineStrikeFactor(labelRectangle, targetPoints[1], lineAngles[1], lineMarking); int selected = 0; - if (compareAngleStraightness(0.0, + if (compareAngleStraightness(0.0, jointPositions[0] > 0.0 ? DrawUtil::angleComposition(lineAngles[0], M_PI) : lineAngles[0], jointPositions[1] > 0.0 ? DrawUtil::angleComposition(lineAngles[1], M_PI) : lineAngles[1], strikeFactors[0], strikeFactors[1]) > 0) { @@ -2166,7 +2158,7 @@ void QGIViewDimension::drawDiameter(TechDraw::DrawViewDimension *dimension, View endPoint.y += curveRadius; lineAngle = M_PI_2; } - + // lineAngle = DrawUtil::angleComposition((labelCenter - curveCenter).Angle(), +M_PI_2); // startPoint = curveCenter - Base::Vector2d::FromPolar(curveRadius, lineAngle); // endPoint = curveCenter + Base::Vector2d::FromPolar(curveRadius, lineAngle); @@ -2201,7 +2193,7 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension *dimension, ViewPro double endAngle = (endPoint - angleVertex).Angle(); double startAngle = (startPoint - angleVertex).Angle(); - double arcRadius; + double arcRadius; int standardStyle = viewProvider->StandardAndStyle.getValue(); int renderExtent = viewProvider->RenderingExtent.getValue(); @@ -2306,7 +2298,7 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension *dimension, ViewPro if (arcRadius < 0.0) { arcRadius = labelDirection.Length(); } - + drawDimensionArc(anglePath, angleVertex, arcRadius, endAngle, startRotation, radiusAngle, labelRectangle, arrowCount, standardStyle, flipArrows); } @@ -2365,43 +2357,29 @@ void QGIViewDimension::drawAngle(TechDraw::DrawViewDimension *dimension, ViewPro QColor QGIViewDimension::prefNormalColor() { - m_colNormal = PreferencesGui::dimQColor(); - -// auto dim( dynamic_cast(getViewObject()) ); - TechDraw::DrawViewDimension* dim = nullptr; - TechDraw::DrawView* dv = getViewObject(); - if (dv) { - dim = dynamic_cast(dv); - if (!dim) - return m_colNormal; - } else { - return m_colNormal; - } + setNormalColor(PreferencesGui::dimQColor()); ViewProviderDimension* vpDim = nullptr; - Gui::ViewProvider* vp = getViewProvider(dim); + Gui::ViewProvider* vp = getViewProvider(getDimFeat()); if (vp) { vpDim = dynamic_cast(vp); - if (!vpDim) - return m_colNormal; - } else { - return m_colNormal; + if (vpDim) { + App::Color fcColor = vpDim->Color.getValue(); + setNormalColor(fcColor.asValue()); + } } - - App::Color fcColor = vpDim->Color.getValue(); - m_colNormal = fcColor.asValue(); - return m_colNormal; + return getNormalColor(); } //! find the closest isometric axis given an ortho vector Base::Vector3d QGIViewDimension::findIsoDir(Base::Vector3d ortho) const { - std::vector isoDirs = { Base::Vector3d(0.866,0.5,0.0), //iso X - Base::Vector3d(-0.866,-0.5,0.0), //iso -X - Base::Vector3d(-0.866,0.5,0.0), //iso -Y? - Base::Vector3d(0.866,-0.5,0.0), //iso +Y? - Base::Vector3d(0.0,-1.0,0.0), //iso -Z - Base::Vector3d(0.0,1.0,0.0) }; //iso Z + std::vector isoDirs = { Base::Vector3d(0.866, 0.5, 0.0), //iso X + Base::Vector3d(-0.866, -0.5, 0.0), //iso -X + Base::Vector3d(-0.866, 0.5, 0.0), //iso -Y? + Base::Vector3d(0.866, -0.5, 0.0), //iso +Y? + Base::Vector3d(0.0, -1.0, 0.0), //iso -Z + Base::Vector3d(0.0, 1.0, 0.0) }; //iso Z std::vector angles; for (auto& iso: isoDirs) { angles.push_back(ortho.GetAngle(iso)); @@ -2420,13 +2398,13 @@ Base::Vector3d QGIViewDimension::findIsoDir(Base::Vector3d ortho) const //! find the iso extension direction corresponding to an iso dist direction Base::Vector3d QGIViewDimension::findIsoExt(Base::Vector3d dir) const { - Base::Vector3d dirExt(1,0,0); - Base::Vector3d isoX(0.866,0.5,0.0); //iso X - Base::Vector3d isoXr(-0.866,-0.5,0.0); //iso -X - Base::Vector3d isoY(-0.866,0.5,0.0); //iso -Y? - Base::Vector3d isoYr(0.866,-0.5,0.0); //iso +Y? - Base::Vector3d isoZ(0.0,1.0,0.0); //iso Z - Base::Vector3d isoZr(0.0,-1.0,0.0); //iso -Z + Base::Vector3d dirExt(1, 0,0); + Base::Vector3d isoX(0.866, 0.5, 0.0); //iso X + Base::Vector3d isoXr(-0.866, -0.5, 0.0); //iso -X + Base::Vector3d isoY(-0.866, 0.5, 0.0); //iso -Y? + Base::Vector3d isoYr(0.866, -0.5, 0.0); //iso +Y? + Base::Vector3d isoZ(0.0, 1.0, 0.0); //iso Z + Base::Vector3d isoZr(0.0, -1.0, 0.0); //iso -Z if (dir.IsEqual(isoX, FLT_EPSILON)) { dirExt = isoY; } else if (dir.IsEqual(-isoX, FLT_EPSILON)) { @@ -2487,7 +2465,7 @@ void QGIViewDimension::drawBorder() double QGIViewDimension::getDefaultExtensionLineOverhang() const { - // 8x Line Width according to ISO 129-1 Standard section 5.4, not specified by ASME Y14.5M + // 8x Line Width according to ISO 129-1 Standard section 5.4, not specified by ASME Y14.5M return Rez::appX(m_lineWidth*8.0); } @@ -2567,34 +2545,32 @@ void QGIViewDimension::setPens() aHead2->setWidth(m_lineWidth); } -double QGIViewDimension::toDeg(double a) +double QGIViewDimension::toDeg(double angle) { - return a*180/M_PI; + return angle*180/M_PI; } -double QGIViewDimension::toQtRad(double a) +double QGIViewDimension::toQtRad(double angle) { - return -a; + return -angle; } -double QGIViewDimension::toQtDeg(double a) +double QGIViewDimension::toQtDeg(double angle) { - return -a*180.0/M_PI; + return -angle*180.0/M_PI; } -void QGIViewDimension::makeMarkC(double x, double y, QColor c) const +void QGIViewDimension::makeMarkC(double xPos, double yPos, QColor color) const { QGIVertex* vItem = new QGIVertex(-1); vItem->setParentItem(const_cast(this)); - vItem->setPos(x,y); + vItem->setPos(xPos, yPos); vItem->setWidth(2.0); vItem->setRadius(20.0); - vItem->setNormalColor(c); - vItem->setFillColor(c); + vItem->setNormalColor(color); + vItem->setFillColor(color); vItem->setPrettyNormal(); vItem->setZValue(ZVALUE::VERTEX); } - - #include diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.h b/src/Mod/TechDraw/Gui/QGIViewDimension.h index 396052f4e8..77a929e61d 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.h +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.h @@ -61,7 +61,7 @@ Q_OBJECT public: QGIDatumLabel(); - ~QGIDatumLabel() override = default; + ~QGIDatumLabel() = default; enum {Type = QGraphicsItem::UserType + 107}; int type() const override { return Type;} @@ -75,20 +75,17 @@ public: void setPosFromCenter(const double &xCenter, const double &yCenter); double X() const { return posX; } double Y() const { return posY; } //minus posY? - - void setFont(QFont f); - QFont getFont() { return m_dimText->font(); } - void setDimString(QString t); - void setDimString(QString t, qreal maxWidth); - void setUnitString(QString t); + + void setFont(QFont font); + QFont getFont() const { return m_dimText->font(); } + void setDimString(QString text); + void setDimString(QString text, qreal maxWidth); + void setUnitString(QString text); void setToleranceString(); void setPrettySel(); void setPrettyPre(); void setPrettyNormal(); - void setColor(QColor c); - - bool verticalSep; - std::vector seps; + void setColor(QColor color); QGCustomText* getDimText() { return m_dimText; } void setDimText(QGCustomText* newText) { m_dimText = newText; } @@ -98,14 +95,13 @@ public: void setTolTextUnder(QGCustomText* newTol) { m_tolTextOver = newTol; } double getTolAdjust(); -/* bool hasHover;*/ - QGIViewDimension* parent; - bool isFramed() { return m_isFramed; } + bool isFramed() const { return m_isFramed; } void setFramed(bool framed) { m_isFramed = framed; } - double getLineWidth() { return m_lineWidth; } + double getLineWidth() const { return m_lineWidth; } void setLineWidth(double lineWidth) { m_lineWidth = lineWidth; } + void setQDim(QGIViewDimension* qDim) { parent = qDim;} Q_SIGNALS: void setPretty(int state); @@ -121,11 +117,23 @@ protected: void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; void mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event) override; + int getPrecision(); + + bool getVerticalSep() const { return verticalSep; } + void setVerticalSep(bool sep) { verticalSep = sep; } + std::vector getSeps() const { return seps; } + void setSeps(std::vector newSeps) { seps = newSeps; } + +private: + bool verticalSep; + std::vector seps; + + QGIViewDimension* parent; + QGCustomText* m_dimText; QGCustomText* m_tolTextOver; QGCustomText* m_tolTextUnder; QGCustomText* m_unitText; - int getPrecision(); QColor m_colNormal; bool m_ctrl; @@ -136,7 +144,7 @@ protected: double m_lineWidth; int m_dragState; - + private: }; @@ -150,7 +158,7 @@ public: enum {Type = QGraphicsItem::UserType + 106}; explicit QGIViewDimension(); - ~QGIViewDimension() override = default; + ~QGIViewDimension() = default; void setViewPartFeature(TechDraw::DrawViewDimension *obj); int type() const override { return Type;} @@ -159,19 +167,19 @@ public: const QStyleOptionGraphicsItem * option, QWidget * widget = nullptr ) override; - TechDraw::DrawViewDimension *dvDimension; void drawBorder() override; void updateView(bool update = false) override; - virtual QColor prefNormalColor(); + QColor prefNormalColor(); QString getLabelText(); void setPrettyPre(); void setPrettySel(); void setPrettyNormal(); - void setGroupSelection(bool b) override; - virtual QGIDatumLabel* getDatumLabel() { return datumLabel; } + void setGroupSelection(bool isSelected) override; + virtual QGIDatumLabel* getDatumLabel() const { return datumLabel; } void setNormalColorAll(); + TechDraw::DrawViewDimension* getDimFeat() { return dvDimension; } public Q_SLOTS: void onPrettyChanged(int state); @@ -182,7 +190,6 @@ public Q_SLOTS: void updateDim(); protected: - void mousePressEvent( QGraphicsSceneMouseEvent * event) override; void mouseMoveEvent( QGraphicsSceneMouseEvent * event) override; void mouseReleaseEvent( QGraphicsSceneMouseEvent * event) override; @@ -256,7 +263,7 @@ protected: void drawRadius(TechDraw::DrawViewDimension *dimension, ViewProviderDimension *viewProvider) const; void drawDiameter(TechDraw::DrawViewDimension *dimension, ViewProviderDimension *viewProvider) const; void drawAngle(TechDraw::DrawViewDimension *dimension, ViewProviderDimension *viewProvider) const; - + QVariant itemChange( GraphicsItemChange change, const QVariant &value ) override; virtual void setSvgPens(); @@ -265,32 +272,23 @@ protected: Base::Vector3d findIsoExt(Base::Vector3d isoDir) const; QString getPrecision(); - bool hasHover; - QGIDatumLabel* datumLabel; //dimension text - QGIDimLines* dimLines; //dimension lines + extension lines - QGIArrow* aHead1; - QGIArrow* aHead2; - //QGICMark* centerMark - double m_lineWidth; - void arrowPositionsToFeature(const Base::Vector2d positions[]) const; - void makeMarkC(double x, double y, QColor c = Qt::red) const; - + void makeMarkC(double xPos, double yPos, QColor color = Qt::red) const; private: - static inline Base::Vector2d fromQtApp(const Base::Vector3d &v) { return Base::Vector2d(v.x, -v.y); } - static inline Base::BoundBox2d fromQtGui(const QRectF &r) - { return Base::BoundBox2d(Rez::appX(r.left()), -Rez::appX(r.top()), - Rez::appX(r.right()), -Rez::appX(r.bottom())); } + static inline Base::Vector2d fromQtApp(const Base::Vector3d &vec3) { return {vec3.x, -vec3.y}; } + static inline Base::BoundBox2d fromQtGui(const QRectF &rect) + { return { Rez::appX(rect.left()), -Rez::appX(rect.top()), + Rez::appX(rect.right()), -Rez::appX(rect.bottom()) }; } - static inline QPointF toQtGui(const Base::Vector2d &v) { return QPointF(Rez::guiX(v.x), -Rez::guiX(v.y)); } - static inline QRectF toQtGui(const Base::BoundBox2d &r) - { return QRectF(Rez::guiX(r.MinX), -Rez::guiX(r.MaxY), - Rez::guiX(r.Width()), Rez::guiX(r.Height())); } + static inline QPointF toQtGui(const Base::Vector2d &vec2) { return {Rez::guiX(vec2.x), -Rez::guiX(vec2.y)}; } + static inline QRectF toQtGui(const Base::BoundBox2d &rect) + { return {Rez::guiX(rect.MinX), -Rez::guiX(rect.MaxY), + Rez::guiX(rect.Width()), Rez::guiX(rect.Height())}; } - static double toDeg(double a); - static double toQtRad(double a); - static double toQtDeg(double a); + static double toDeg(double angle); + static double toQtRad(double angle); + static double toQtDeg(double angle); double getDefaultExtensionLineOverhang() const; double getDefaultArrowTailLength() const; @@ -298,8 +296,13 @@ private: double getDefaultIsoReferenceLineOverhang() const; double getDefaultAsmeHorizontalLeaderLength() const; -/* QGIView* m_parent; //for edit dialog set up eventually*/ - + TechDraw::DrawViewDimension *dvDimension; + bool hasHover; + QGIDatumLabel* datumLabel; //dimension text + QGIDimLines* dimLines; //dimension lines + extension lines + QGIArrow* aHead1; + QGIArrow* aHead2; + double m_lineWidth; }; } // namespace MDIViewPageGui diff --git a/src/Mod/TechDraw/Gui/QGIViewImage.cpp b/src/Mod/TechDraw/Gui/QGIViewImage.cpp index 9774ce2f55..083560578b 100644 --- a/src/Mod/TechDraw/Gui/QGIViewImage.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewImage.cpp @@ -62,13 +62,13 @@ QGIViewImage::QGIViewImage() m_cliparea = new QGCustomClip(); addToGroup(m_cliparea); - m_cliparea->setRect(0.,0.,5.,5.); - m_cliparea->centerAt(0.,0.); + m_cliparea->setRect(0., 0., 5., 5.); + m_cliparea->centerAt(0., 0.); m_imageItem = new QGCustomImage(); m_imageItem->setTransformationMode(Qt::SmoothTransformation); m_cliparea->addToGroup(m_imageItem); - m_imageItem->centerAt(0.,0.); + m_imageItem->centerAt(0., 0.); } QGIViewImage::~QGIViewImage() @@ -119,13 +119,13 @@ void QGIViewImage::draw() drawImage(); if (crop) { - QRectF cropRect(0.0,0.0,Rez::guiX(viewImage->Width.getValue()),Rez::guiX(viewImage->Height.getValue())); + QRectF cropRect(0.0, 0.0, Rez::guiX(viewImage->Width.getValue()), Rez::guiX(viewImage->Height.getValue())); m_cliparea->setRect(cropRect); } else { QRectF cropRect(0.0, 0.0, m_imageItem->imageSize().width(), m_imageItem->imageSize().height()); m_cliparea->setRect(cropRect); } - m_cliparea->centerAt(0.0,0.0); + m_cliparea->centerAt(0.0, 0.0); drawImage(); } @@ -137,13 +137,13 @@ void QGIViewImage::drawImage() return; if (!viewImage->ImageIncluded.isEmpty()) { - QString fileSpec = QString::fromUtf8(viewImage->ImageIncluded.getValue(),strlen(viewImage->ImageIncluded.getValue())); + QString fileSpec = QString::fromUtf8(viewImage->ImageIncluded.getValue(), strlen(viewImage->ImageIncluded.getValue())); m_imageItem->load(fileSpec); m_imageItem->setScale(viewImage->getScale()); QRectF br = m_cliparea->rect(); double midX = br.width()/2.0; double midY = br.height()/2.0; - m_imageItem->centerAt(midX,midY); + m_imageItem->centerAt(midX, midY); m_imageItem->show(); } } diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 44c04b080d..20695adcdf 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -74,9 +74,6 @@ #include "QGISectionLine.h" #include "QGICenterLine.h" #include "QGIHighlight.h" -#include "QGCustomBorder.h" -#include "QGCustomLabel.h" -#include "QGCustomRect.h" #include "QGIMatting.h" #include "QGIViewPart.h" #include "ViewProviderGeomHatch.h" @@ -104,7 +101,7 @@ QGIViewPart::QGIViewPart() : setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, true); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); showSection = false; } @@ -145,7 +142,7 @@ void QGIViewPart::setViewPartFeature(TechDraw::DrawViewPart *obj) QPainterPath QGIViewPart::drawPainterPath(TechDraw::BaseGeomPtr baseGeom) const { double rot = getViewObject()->Rotation.getValue(); - return geomToPainterPath(baseGeom,rot); + return geomToPainterPath(baseGeom, rot); } @@ -167,7 +164,7 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) path.addEllipse(Rez::guiX(x), Rez::guiX(y), Rez::guiX(geom->radius * 2), - Rez::guiX(geom->radius * 2)); //topleft@(x,y) radx,rady + Rez::guiX(geom->radius * 2)); //topleft@(x, y) radx, rady } break; case ARCOFCIRCLE: { @@ -282,8 +279,8 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) path.cubicTo(Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y), Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y), Rez::guiX(geom->pnts[0].x), Rez::guiX(geom->pnts[0].y)); - } else { //can only handle lines,quads,cubes - Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles); + } else { //can only handle lines, quads, cubes + Base::Console().Error("Bad pole count (%d) for BezierSegment\n", geom->poles); auto itBez = geom->pnts.begin() + 1; for (; itBez != geom->pnts.end();itBez++) { path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging @@ -305,8 +302,8 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) path.cubicTo(Rez::guiX(geom->pnts[1].x), Rez::guiX(geom->pnts[1].y), Rez::guiX(geom->pnts[2].x), Rez::guiX(geom->pnts[2].y), Rez::guiX(geom->pnts[3].x), Rez::guiX(geom->pnts[3].y)); - } else { //can only handle lines,quads,cubes - Base::Console().Error("Bad pole count (%d) for BezierSegment\n",geom->poles); + } else { //can only handle lines, quads, cubes + Base::Console().Error("Bad pole count (%d) for BezierSegment\n", geom->poles); auto itBez = geom->pnts.begin() + 1; for (; itBez != geom->pnts.end();itBez++) { path.lineTo(Rez::guiX((*itBez).x), Rez::guiX((*itBez).y)); //show something for debugging @@ -337,7 +334,7 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) path.cubicTo(Rez::guiX(it->pnts[2].x), Rez::guiX(it->pnts[2].y), Rez::guiX(it->pnts[1].x), Rez::guiX(it->pnts[1].y), Rez::guiX(it->pnts[0].x), Rez::guiX(it->pnts[0].y)); - } else { //can only handle lines,quads,cubes + } else { //can only handle lines, quads, cubes Base::Console().Error("Bad pole count (%d) for BezierSegment of B-spline geometry\n", it->poles); path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging @@ -366,8 +363,8 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) it->poles); path.lineTo(it->pnts[1].x, it->pnts[1].y); //show something for debugging } - } - } + } + } } break; case TechDraw::GENERIC: { @@ -391,7 +388,7 @@ QPainterPath QGIViewPart::geomToPainterPath(BaseGeomPtr baseGeom, double rot) } break; default: { - Base::Console().Error("Error - geomToPainterPath - UNKNOWN geomType: %d\n",baseGeom->geomType); + Base::Console().Error("Error - geomToPainterPath - UNKNOWN geomType: %d\n", baseGeom->geomType); } break; } //sb end of switch @@ -465,11 +462,11 @@ void QGIViewPart::drawViewPart() const std::vector &faceGeoms = viewPart->getFaceGeometry(); std::vector::const_iterator fit = faceGeoms.begin(); for(int i = 0 ; fit != faceGeoms.end(); fit++, i++) { - QGIFace* newFace = drawFace(*fit,i); + QGIFace* newFace = drawFace(*fit, i); newFace->isHatched(false); newFace->setFillMode(QGIFace::PlainFill); - TechDraw::DrawHatch* fHatch = faceIsHatched(i,hatchObjs); - TechDraw::DrawGeomHatch* fGeom = faceIsGeomHatched(i,geomObjs); + TechDraw::DrawHatch* fHatch = faceIsHatched(i, hatchObjs); + TechDraw::DrawGeomHatch* fGeom = faceIsGeomHatched(i, geomObjs); if (fGeom) { const std::vector &sourceNames = fGeom->Source.getSubValues(); if (!sourceNames.empty()) { @@ -569,7 +566,7 @@ void QGIViewPart::drawViewPart() std::string cTag = (*itGeom)->getCosmeticTag(); showItem = formatGeomFromCenterLine(cTag, item); } else { - Base::Console().Message("QGIVP::drawVP - edge: %d is confused - source: %d\n",i,source); + Base::Console().Message("QGIVP::drawVP - edge: %d is confused - source: %d\n", i,source); } } else { TechDraw::GeomFormat* gf = viewPart->getGeomFormatBySelection(i); @@ -581,8 +578,8 @@ void QGIViewPart::drawViewPart() } } - addToGroup(item); //item is at scene(0,0), not group(0,0) - item->setPos(0.0,0.0); //now at group(0,0) + addToGroup(item); //item is at scene(0, 0), not group(0, 0) + item->setPos(0.0, 0.0); //now at group(0, 0) item->setPath(drawPainterPath(*itGeom)); item->setZValue(ZVALUE::EDGE); if(!(*itGeom)->hlrVisible) { @@ -603,7 +600,7 @@ void QGIViewPart::drawViewPart() // QPainterPath edgePath=drawPainterPath(*itGeom); // std::stringstream edgeId; // edgeId << "QGIVP.edgePath" << i; -// dumpPath(edgeId.str().c_str(),edgePath); +// dumpPath(edgeId.str().c_str(), edgePath); } } @@ -687,7 +684,7 @@ bool QGIViewPart::formatGeomFromCosmetic(std::string cTag, QGIEdge* item) bool QGIViewPart::formatGeomFromCenterLine(std::string cTag, QGIEdge* item) { -// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n",sourceIndex); +// Base::Console().Message("QGIVP::formatGeomFromCenterLine(%d)\n", sourceIndex); bool result = true; auto partFeat( dynamic_cast(getViewObject()) ); TechDraw::CenterLine* cl = partFeat ? partFeat->getCenterLine(cTag) : nullptr; @@ -734,24 +731,24 @@ QGIFace* QGIViewPart::drawFace(TechDraw::FacePtr f, int idx) } wirePath.connectPath(edgePath); } -// dumpPath("wirePath:",wirePath); +// dumpPath("wirePath:", wirePath); facePath.addPath(wirePath); } facePath.setFillRule(Qt::OddEvenFill); QGIFace* gFace = new QGIFace(idx); addToGroup(gFace); - gFace->setPos(0.0,0.0); + gFace->setPos(0.0, 0.0); gFace->setOutline(facePath); //debug a path //std::stringstream faceId; //faceId << "facePath " << idx; - //dumpPath(faceId.str().c_str(),facePath); + //dumpPath(faceId.str().c_str(), facePath); return gFace; } -//! Remove all existing QGIPrimPath items(Vertex,Edge,Face) +//! Remove all existing QGIPrimPath items(Vertex, Edge, Face) //note this triggers scene selectionChanged signal if vertex/edge/face is selected void QGIViewPart::removePrimitives() { @@ -773,7 +770,7 @@ void QGIViewPart::removePrimitives() } } -//! Remove all existing QGIDecoration items(SectionLine,SectionMark,...) +//! Remove all existing QGIDecoration items(SectionLine, SectionMark, ...) void QGIViewPart::removeDecorations() { QList children = childItems(); @@ -850,14 +847,14 @@ void QGIViewPart::drawSectionLine(TechDraw::DrawViewSection* viewSection, bool b //make the section line a little longer double fudge = Rez::guiX(2.0 * Preferences::dimFontSizeMM()); - sectionLine->setEnds(l1 - lineDir * fudge, + sectionLine->setEnds(l1 - lineDir * fudge, l2 + lineDir * fudge); //set the general parameters sectionLine->setPos(0.0, 0.0); sectionLine->setWidth(Rez::guiX(vp->LineWidth.getValue())); double fontSize = Preferences::dimFontSizeMM(); - sectionLine->setFont(m_font, fontSize); + sectionLine->setFont(getFont(), fontSize); sectionLine->setZValue(ZVALUE::SECTIONLINE); sectionLine->setRotation(- viewPart->Rotation.getValue()); sectionLine->draw(); @@ -886,7 +883,7 @@ void QGIViewPart::drawCenterLines(bool b) if (horiz) { centerLine = new QGICenterLine(); addToGroup(centerLine); - centerLine->setPos(0.0,0.0); + centerLine->setPos(0.0, 0.0); //this should work from the viewPart's bbox, not the border // double scale = viewPart->getScale(); double width = Rez::guiX(viewPart->getBoxX()); @@ -895,7 +892,7 @@ void QGIViewPart::drawCenterLines(bool b) xVal = sectionSpan / 2.0; yVal = 0.0; centerLine->setIntersection(horiz && vert); - centerLine->setBounds(-xVal,-yVal,xVal,yVal); + centerLine->setBounds(-xVal, -yVal, xVal, yVal); centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue())); centerLine->setZValue(ZVALUE::SECTIONLINE); // centerLine->setRotation(viewPart->Rotation.getValue()); @@ -904,7 +901,7 @@ void QGIViewPart::drawCenterLines(bool b) if (vert) { centerLine = new QGICenterLine(); addToGroup(centerLine); - centerLine->setPos(0.0,0.0); + centerLine->setPos(0.0, 0.0); // double scale = viewPart->getScale(); double height = Rez::guiX(viewPart->getBoxY()); sectionSpan = height + sectionFudge; @@ -912,7 +909,7 @@ void QGIViewPart::drawCenterLines(bool b) xVal = 0.0; yVal = sectionSpan / 2.0; centerLine->setIntersection(horiz && vert); - centerLine->setBounds(-xVal,-yVal,xVal,yVal); + centerLine->setBounds(-xVal, -yVal, xVal, yVal); centerLine->setWidth(Rez::guiX(vp->HiddenWidth.getValue())); centerLine->setZValue(ZVALUE::SECTIONLINE); // centerLine->setRotation(viewPart->Rotation.getValue()); @@ -938,7 +935,7 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b) double fontSize = Preferences::labelFontSizeMM(); QGIHighlight* highlight = new QGIHighlight(); addToGroup(highlight); - highlight->setPos(0.0,0.0); //sb setPos(center.x,center.y)? + highlight->setPos(0.0, 0.0); //sb setPos(center.x, center.y)? highlight->setReference(viewDetail->Reference.getValue()); highlight->setStyle((Qt::PenStyle)vp->HighlightLineStyle.getValue()); highlight->setColor(vp->HighlightLineColor.getValue().asValue()); @@ -946,15 +943,15 @@ void QGIViewPart::drawHighlight(TechDraw::DrawViewDetail* viewDetail, bool b) Base::Vector3d center = viewDetail->AnchorPoint.getValue() * viewPart->getScale(); double radius = viewDetail->Radius.getValue() * viewPart->getScale(); - highlight->setBounds(center.x - radius, center.y + radius,center.x + radius, center.y - radius); + highlight->setBounds(center.x - radius, center.y + radius, center.x + radius, center.y - radius); highlight->setWidth(Rez::guiX(vp->IsoWidth.getValue())); - highlight->setFont(m_font, fontSize); + highlight->setFont(getFont(), fontSize); highlight->setZValue(ZVALUE::HIGHLIGHT); QPointF rotCenter = highlight->mapFromParent(transformOriginPoint()); highlight->setTransformOriginPoint(rotCenter); - double rotation = viewPart->Rotation.getValue() + + double rotation = viewPart->Rotation.getValue() + vp->HighlightAdjust.getValue(); highlight->setRotation(rotation); highlight->draw(); @@ -976,7 +973,7 @@ void QGIViewPart::drawMatting() QGIMatting* mat = new QGIMatting(); addToGroup(mat); mat->setRadius(Rez::guiX(radius)); - mat->setPos(0.0,0.0); + mat->setPos(0.0, 0.0); mat->draw(); mat->show(); } @@ -1123,7 +1120,7 @@ void QGIViewPart::toggleCosmeticLines(bool state) } //get hatchObj for face i if it exists -TechDraw::DrawHatch* QGIViewPart::faceIsHatched(int i,std::vector hatchObjs) const +TechDraw::DrawHatch* QGIViewPart::faceIsHatched(int i, std::vector hatchObjs) const { TechDraw::DrawHatch* result = nullptr; bool found = false; @@ -1144,7 +1141,7 @@ TechDraw::DrawHatch* QGIViewPart::faceIsHatched(int i,std::vector geomObjs) const +TechDraw::DrawGeomHatch* QGIViewPart::faceIsGeomHatched(int i, std::vector geomObjs) const { TechDraw::DrawGeomHatch* result = nullptr; bool found = false; @@ -1166,10 +1163,10 @@ TechDraw::DrawGeomHatch* QGIViewPart::faceIsGeomHatched(int i,std::vector>>%s has %d elements\n",text,path.elementCount()); + Base::Console().Message(">>>%s has %d elements\n", text, path.elementCount()); char* typeName; for(int iElem = 0; iElem < path.elementCount(); iElem++) { elem = path.elementAt(iElem); @@ -1182,7 +1179,7 @@ void QGIViewPart::dumpPath(const char* text,QPainterPath path) } else { typeName = "CurveData"; } - Base::Console().Message(">>>>> element %d: type:%d/%s pos(%.3f,%.3f) M:%d L:%d C:%d\n", + Base::Console().Message(">>>>> element %d: type:%d/%s pos(%.3f, %.3f) M:%d L:%d C:%d\n", iElem, elem.type, typeName, elem.x, elem.y, elem.isMoveTo(), elem.isLineTo(), elem.isCurveTo()); } diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.h b/src/Mod/TechDraw/Gui/QGIViewPart.h index fb944d0337..b502d34cad 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.h +++ b/src/Mod/TechDraw/Gui/QGIViewPart.h @@ -83,7 +83,7 @@ public: * x_axis_rotation is in radian */ static void pathArcSegment(QPainterPath &path, double xc, double yc, double th0, - double th1,double rx, double ry, double xAxisRotation); + double th1, double rx, double ry, double xAxisRotation); /// Draws an arc using QPainterPath path /*! @@ -103,9 +103,9 @@ protected: QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; - TechDraw::DrawHatch* faceIsHatched(int i,std::vector hatchObjs) const; - TechDraw::DrawGeomHatch* faceIsGeomHatched(int i,std::vector geomObjs) const; - void dumpPath(const char* text,QPainterPath path); + TechDraw::DrawHatch* faceIsHatched(int i, std::vector hatchObjs) const; + TechDraw::DrawGeomHatch* faceIsGeomHatched(int i, std::vector geomObjs) const; + void dumpPath(const char* text, QPainterPath path); void removePrimitives(); void removeDecorations(); bool prefFaceEdges(); diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index 44d98de155..3aad751c52 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -90,7 +90,7 @@ void QGIViewSection::drawSectionFace() std::vector::iterator fit = sectionFaces.begin(); int i = 0; for(; fit != sectionFaces.end(); fit++, i++) { - QGIFace* newFace = drawFace(*fit,-1); + QGIFace* newFace = drawFace(*fit, -1); newFace->setZValue(ZVALUE::SECTIONFACE); if (section->showSectionEdges()) { newFace->setDrawEdges(true); @@ -134,7 +134,7 @@ void QGIViewSection::drawSectionFace() } } } else { - Base::Console().Warning("QGIVS::draw - unknown CutSurfaceDisplay: %d\n", + Base::Console().Warning("QGIVS::draw - unknown CutSurfaceDisplay: %d\n", section->CutSurfaceDisplay.getValue()); } diff --git a/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp b/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp index 1f909f7e0d..74dbb63871 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSymbol.cpp @@ -64,11 +64,11 @@ QGIViewSymbol::QGIViewSymbol() m_displayArea = new QGDisplayArea(); addToGroup(m_displayArea); - m_displayArea->centerAt(0.,0.); + m_displayArea->centerAt(0., 0.); m_svgItem = new QGCustomSvg(); m_displayArea->addToGroup(m_svgItem); - m_svgItem->centerAt(0.,0.); + m_svgItem->centerAt(0., 0.); } QGIViewSymbol::~QGIViewSymbol() @@ -131,7 +131,7 @@ void QGIViewSymbol::drawSvg() } m_svgItem->setScale(scaling); - QByteArray qba(viewSymbol->Symbol.getValue(),strlen(viewSymbol->Symbol.getValue())); + QByteArray qba(viewSymbol->Symbol.getValue(), strlen(viewSymbol->Symbol.getValue())); symbolToSvg(qba); rotateView(); } @@ -146,7 +146,7 @@ void QGIViewSymbol::symbolToSvg(QByteArray qba) if (!m_svgItem->load(&qba)) { Base::Console().Error("Error - Could not load Symbol into SVG renderer for %s\n", getViewName()); } - m_svgItem->centerAt(0.,0.); + m_svgItem->centerAt(0., 0.); } void QGIViewSymbol::rotateView() diff --git a/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp b/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp index ce1d059123..e438d06653 100644 --- a/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp +++ b/src/Mod/TechDraw/Gui/QGIWeldSymbol.cpp @@ -58,13 +58,9 @@ #include //#include -#include "Rez.h" #include "ZVALUE.h" #include "PreferencesGui.h" #include "ViewProviderWeld.h" -#include "MDIViewPage.h" -#include "DrawGuiUtil.h" -#include "QGVPage.h" #include "QGIPrimPath.h" #include "QGITile.h" #include "QGILeaderLine.h" @@ -88,7 +84,7 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) : { setFiltersChildEvents(true); //qt5 setFlag(QGraphicsItem::ItemIsMovable, false); - + setCacheMode(QGraphicsItem::NoCache); setParentItem(m_qgLead); @@ -109,7 +105,7 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) : m_allAround->setFlag(QGraphicsItem::ItemIsSelectable, false); m_allAround->setFlag(QGraphicsItem::ItemIsMovable, false); m_allAround->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); - m_allAround->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + m_allAround->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); m_allAround->setFlag(QGraphicsItem::ItemStacksBehindParent, true); m_fieldFlag = new QGIPrimPath(); @@ -119,12 +115,13 @@ QGIWeldSymbol::QGIWeldSymbol(QGILeaderLine* myParent) : m_fieldFlag->setFlag(QGraphicsItem::ItemIsSelectable, false); m_fieldFlag->setFlag(QGraphicsItem::ItemIsMovable, false); m_fieldFlag->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, false); - m_fieldFlag->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + m_fieldFlag->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); m_fieldFlag->setFlag(QGraphicsItem::ItemStacksBehindParent, true); m_fieldFlag->setFill(prefNormalColor(), Qt::SolidPattern); - m_colCurrent = prefNormalColor(); - m_colSetting = m_colCurrent; + setNormalColor(prefNormalColor()); + setCurrentColor(getNormalColor()); + setSettingColor(getNormalColor()); setPrettyNormal(); } @@ -240,7 +237,7 @@ void QGIWeldSymbol::drawAllAround() if (getFeature()->AllAround.getValue()) { m_allAround->show(); } else { - + m_allAround->hide(); return; } @@ -259,7 +256,7 @@ void QGIWeldSymbol::drawTailText() { // Base::Console().Message("QGIWS::drawTailText()\n"); QPointF textPos = getTailPoint(); - m_tailText->setPos(textPos); //avoid messing up brect with empty item at 0,0 !!! + m_tailText->setPos(textPos); //avoid messing up brect with empty item at 0, 0 !!! std::string tText = getFeature()->TailText.getValue(); if (tText.empty()) { m_tailText->hide(); @@ -305,7 +302,7 @@ void QGIWeldSymbol::drawFieldFlag() { // Base::Console().Message("QGIWS::drawFieldFlag()\n"); QPointF fieldFlagPos = getKinkPoint(); - m_fieldFlag->setPos(fieldFlagPos); + m_fieldFlag->setPos(fieldFlagPos); if (getFeature()->FieldWeld.getValue()) { m_fieldFlag->show(); @@ -340,12 +337,12 @@ void QGIWeldSymbol::getTileFeats() std::vector tiles = getFeature()->getTiles(); m_arrowFeat = nullptr; m_otherFeat = nullptr; - + if (!tiles.empty()) { TechDraw::DrawTileWeld* tempTile = tiles.at(0); if (tempTile->TileRow.getValue() == 0) { m_arrowFeat = tempTile; - } else { + } else { m_otherFeat = tempTile; } } @@ -353,7 +350,7 @@ void QGIWeldSymbol::getTileFeats() TechDraw::DrawTileWeld* tempTile = tiles.at(1); if (tempTile->TileRow.getValue() == 0) { m_arrowFeat = tempTile; - } else { + } else { m_otherFeat = tempTile; } } @@ -392,10 +389,10 @@ void QGIWeldSymbol::hoverEnterEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); if (isSelected()) { - m_colCurrent = getSelectColor(); + setCurrentColor(getSelectColor()); setPrettySel(); } else { - m_colCurrent = getPreColor(); + setCurrentColor(getPreColor()); setPrettyPre(); } QGIView::hoverEnterEvent(event); @@ -405,10 +402,10 @@ void QGIWeldSymbol::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) { Q_UNUSED(event); if(isSelected()) { - m_colCurrent = getSelectColor(); + setCurrentColor(getSelectColor()); setPrettySel(); } else { - m_colCurrent = m_colNormal; + setCurrentColor(getNormalColor()); setPrettyNormal(); } QGIView::hoverLeaveEvent(event); @@ -424,15 +421,15 @@ void QGIWeldSymbol::setPrettyNormal() { std::vector tiles = getQGITiles(); for (auto t: tiles) { - t->setColor(m_colNormal); + t->setColor(getNormalColor()); t->draw(); } - m_colCurrent = m_colNormal; - m_fieldFlag->setNormalColor(m_colCurrent); + setCurrentColor(getNormalColor()); + m_fieldFlag->setNormalColor(getNormalColor()); m_fieldFlag->setPrettyNormal(); - m_allAround->setNormalColor(m_colCurrent); + m_allAround->setNormalColor(getNormalColor()); m_allAround->setPrettyNormal(); - m_tailText->setColor(m_colCurrent); + m_tailText->setColor(getNormalColor()); m_tailText->setPrettyNormal(); } @@ -444,7 +441,7 @@ void QGIWeldSymbol::setPrettyPre() t->draw(); } - m_colCurrent = getPreColor(); + setCurrentColor(getPreColor()); m_fieldFlag->setNormalColor(getPreColor()); m_fieldFlag->setPrettyPre(); m_allAround->setNormalColor(getPreColor()); @@ -461,7 +458,7 @@ void QGIWeldSymbol::setPrettySel() t->draw(); } - m_colCurrent = getSelectColor(); + setCurrentColor(getSelectColor()); m_fieldFlag->setNormalColor(getSelectColor()); m_fieldFlag->setPrettySel(); m_allAround->setNormalColor(getSelectColor()); @@ -506,8 +503,8 @@ TechDraw::DrawWeldSymbol* QGIWeldSymbol::getFeature() //preference QColor QGIWeldSymbol::prefNormalColor() { - m_colNormal = PreferencesGui::leaderQColor(); - return m_colNormal; + setNormalColor(PreferencesGui::leaderQColor()); + return getNormalColor(); } double QGIWeldSymbol::prefArrowSize() diff --git a/src/Mod/TechDraw/Gui/QGMText.cpp b/src/Mod/TechDraw/Gui/QGMText.cpp index 7197bdd413..3e6dba60e9 100644 --- a/src/Mod/TechDraw/Gui/QGMText.cpp +++ b/src/Mod/TechDraw/Gui/QGMText.cpp @@ -46,7 +46,7 @@ QGMText::QGMText() : QVariant QGMText::itemChange(GraphicsItemChange change, const QVariant &value) { - //QPointF newPos(0.0,0.0); + //QPointF newPos(0.0, 0.0); if(change == ItemPositionHasChanged && scene()) { Q_EMIT dragging(); } @@ -99,7 +99,7 @@ void QGMText::paint ( QPainter * painter, const QStyleOptionGraphicsItem * optio // painter->drawRect(boundingRect()); //good for debugging //TODO: this should be changed to a rectItem in the parent if (showBox()) { - painter->drawRect(boundingRect().adjusted(1,1,-1,-1)); + painter->drawRect(boundingRect().adjusted(1, 1,-1, -1)); } QGCustomText::paint (painter, &myOption, widget); diff --git a/src/Mod/TechDraw/Gui/QGSPage.cpp b/src/Mod/TechDraw/Gui/QGSPage.cpp index 1778433a12..d94c90ae79 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.cpp +++ b/src/Mod/TechDraw/Gui/QGSPage.cpp @@ -88,11 +88,9 @@ #include "Rez.h" -#include "PreferencesGui.h" #include "QGIDrawingTemplate.h" #include "QGITemplate.h" #include "QGISVGTemplate.h" -#include "TemplateTextField.h" #include "QGIViewCollection.h" #include "QGIViewDimension.h" #include "QGIViewBalloon.h" @@ -104,11 +102,9 @@ #include "QGIViewClip.h" #include "QGIViewSpreadsheet.h" #include "QGIViewImage.h" -#include "QGIFace.h" #include "QGILeaderLine.h" #include "QGIRichAnno.h" #include "QGIWeldSymbol.h" -#include "QGITile.h" #include "ZVALUE.h" #include "DrawGuiUtil.h" @@ -127,23 +123,18 @@ using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; -QGSPage::QGSPage(ViewProviderPage *vp, QWidget *parent) +QGSPage::QGSPage(ViewProviderPage *vpPage, QWidget *parent) : QGraphicsScene(parent), pageTemplate(nullptr), m_vpPage(nullptr) { - assert(vp); - m_vpPage = vp; + assert(vpPage); + m_vpPage = vpPage; setItemIndexMethod(QGraphicsScene::BspTreeIndex); //the default // setItemIndexMethod(QGraphicsScene::NoIndex); //sometimes faster } -QGSPage::~QGSPage() -{ - -} - -void QGSPage::addChildrenToPage(void) +void QGSPage::addChildrenToPage() { // Base::Console().Message("QGSP::addChildrenToPage()\n"); // A fresh page is added and we iterate through its collected children and add these to Canvas View -MLP @@ -192,7 +183,7 @@ void QGSPage::updateTemplate(bool forceUpdate) App::DocumentObject *templObj = m_vpPage->getDrawPage()->Template.getValue(); // TODO: what if template has been deleted? templObj will be NULL. segfault? if (!templObj) { - Base::Console().Log("INFO - QGSPage::updateTemplate - Page: %s has NO template!!\n",m_vpPage->getDrawPage()->getNameInDocument()); + Base::Console().Log("INFO - QGSPage::updateTemplate - Page: %s has NO template!!\n", m_vpPage->getDrawPage()->getNameInDocument()); return; } @@ -220,7 +211,7 @@ QPointF QGSPage::getTemplateCenter() if( pageTemplate != nullptr ) { double cx = Rez::guiX(pageTemplate->Width.getValue())/2.0; double cy = -Rez::guiX(pageTemplate->Height.getValue())/2.0; - return QPointF(cx,cy); + return QPointF(cx, cy); } return QPointF(0.0, 0.0); } @@ -234,21 +225,21 @@ void QGSPage::matchSceneRectToTemplate(void) //make sceneRect 1 pagesize bigger in every direction double width = Rez::guiX(pageTemplate->Width.getValue()); double height = Rez::guiX(pageTemplate->Height.getValue()); - setSceneRect(QRectF(-width,-2.0 * height,3.0*width,3.0*height)); + setSceneRect(QRectF(-width, -2.0 * height, 3.0*width, 3.0*height)); } } -void QGSPage::setPageTemplate(TechDraw::DrawTemplate *obj) +void QGSPage::setPageTemplate(TechDraw::DrawTemplate *templateFeat) { // Base::Console().Message("QGSP::setPageTemplate()\n"); removeTemplate(); - if(obj->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) { + if(templateFeat->isDerivedFrom(TechDraw::DrawParametricTemplate::getClassTypeId())) { pageTemplate = new QGIDrawingTemplate(this); - } else if(obj->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) { + } else if(templateFeat->isDerivedFrom(TechDraw::DrawSVGTemplate::getClassTypeId())) { pageTemplate = new QGISVGTemplate(this); } - pageTemplate->setTemplate(obj); + pageTemplate->setTemplate(templateFeat); pageTemplate->updateView(); } @@ -298,7 +289,7 @@ int QGSPage::addQView(QGIView *view) if(parent) { // move child view to center of parent - QPointF posRef(0.,0.); + QPointF posRef(0., 0.); QPointF mapPos = view->mapToItem(parent, posRef); view->moveBy(-mapPos.x(), -mapPos.y()); @@ -428,32 +419,32 @@ bool QGSPage::attachView(App::DocumentObject *obj) return (qview != nullptr); } -QGIView * QGSPage::addViewPart(TechDraw::DrawViewPart *part) +QGIView * QGSPage::addViewPart(TechDraw::DrawViewPart *partFeat) { // Base::Console().Message("QGSP::addViewPart(%s)\n", part->getNameInDocument()); auto viewPart( new QGIViewPart ); - viewPart->setViewPartFeature(part); + viewPart->setViewPartFeature(partFeat); addQView(viewPart); return viewPart; } -QGIView * QGSPage::addViewSection(TechDraw::DrawViewPart *part) +QGIView * QGSPage::addViewSection(DrawViewSection *sectionFeat) { auto viewSection( new QGIViewSection ); - viewSection->setViewPartFeature(part); + viewSection->setViewPartFeature(sectionFeat); addQView(viewSection); return viewSection; } -QGIView * QGSPage::addProjectionGroup(TechDraw::DrawProjGroup *view) +QGIView * QGSPage::addProjectionGroup(TechDraw::DrawProjGroup *projGroupFeat) { auto qview( new QGIProjGroup ); - qview->setViewFeature(view); + qview->setViewFeature(projGroupFeat); addQView(qview); return qview; } @@ -467,30 +458,30 @@ QGIView * QGSPage::addDrawView(TechDraw::DrawView *view) return qview; } -QGIView * QGSPage::addDrawViewCollection(TechDraw::DrawViewCollection *view) +QGIView * QGSPage::addDrawViewCollection(TechDraw::DrawViewCollection *collectionFeat) { auto qview( new QGIViewCollection ); - qview->setViewFeature(view); + qview->setViewFeature(collectionFeat); addQView(qview); return qview; } -QGIView * QGSPage::addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view) +QGIView * QGSPage::addDrawViewAnnotation(TechDraw::DrawViewAnnotation *annoFeat) { auto qview( new QGIViewAnnotation ); - qview->setViewAnnoFeature(view); + qview->setViewAnnoFeature(annoFeat); addQView(qview); return qview; } -QGIView * QGSPage::addDrawViewSymbol(TechDraw::DrawViewSymbol *view) +QGIView * QGSPage::addDrawViewSymbol(TechDraw::DrawViewSymbol *symbolFeat) { auto qview( new QGIViewSymbol ); - qview->setViewFeature(view); + qview->setViewFeature(symbolFeat); addQView(qview); return qview; @@ -507,41 +498,40 @@ QGIView * QGSPage::addDrawViewClip(TechDraw::DrawViewClip *view) return qview; } -QGIView * QGSPage::addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view) +QGIView * QGSPage::addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *sheetFeat) { auto qview( new QGIViewSpreadsheet ); - qview->setViewFeature(view); + qview->setViewFeature(sheetFeat); addQView(qview); return qview; } -QGIView * QGSPage::addDrawViewImage(TechDraw::DrawViewImage *view) +QGIView * QGSPage::addDrawViewImage(TechDraw::DrawViewImage *imageFeat) { auto qview( new QGIViewImage ); - qview->setViewFeature(view); + qview->setViewFeature(imageFeat); addQView(qview); return qview; } -QGIView * QGSPage::addViewBalloon(TechDraw::DrawViewBalloon *balloon) +QGIView * QGSPage::addViewBalloon(TechDraw::DrawViewBalloon *balloonFeat) { // Base::Console().Message("QGSP::addViewBalloon(%s)\n", balloon->getNameInDocument()); auto vBalloon( new QGIViewBalloon ); addItem(vBalloon); - vBalloon->setViewPartFeature(balloon); - vBalloon->dvBalloon = balloon; + vBalloon->setViewPartFeature(balloonFeat); QGIView *parent = nullptr; parent = findParent(vBalloon); if (parent) { - addBalloonToParent(vBalloon,parent); + addBalloonToParent(vBalloon, parent); } return vBalloon; @@ -552,7 +542,7 @@ void QGSPage::addBalloonToParent(QGIViewBalloon* balloon, QGIView* parent) // Base::Console().Message("QGSP::addBalloonToParent()\n"); assert(balloon); assert(parent); //blow up if we don't have Dimension or Parent - QPointF posRef(0.,0.); + QPointF posRef(0., 0.); QPointF mapPos = balloon->mapToItem(parent, posRef); balloon->moveBy(-mapPos.x(), -mapPos.y()); parent->addToGroup(balloon); @@ -567,12 +557,12 @@ void QGSPage::createBalloon(QPointF origin, DrawViewPart *parent) std::string pageName = getDrawPage()->getNameInDocument(); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Balloon")); - Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon','%s')", featName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewBalloon', '%s')", featName.c_str()); TechDraw::DrawViewBalloon *balloon = dynamic_cast(getDrawPage()->getDocument()->getObject(featName.c_str())); if (!balloon) { throw Base::TypeError("QGSP::createBalloon - balloon not found\n"); } - Command::doCommand(Command::Doc,"App.activeDocument().%s.SourceView = (App.activeDocument().%s)", + Command::doCommand(Command::Doc, "App.activeDocument().%s.SourceView = (App.activeDocument().%s)", featName.c_str(), parent->getNameInDocument()); QGIView* qgParent = getQGIVByName(parent->getNameInDocument()); @@ -596,21 +586,20 @@ void QGSPage::createBalloon(QPointF origin, DrawViewPart *parent) Gui::Command::commitCommand(); } -QGIView * QGSPage::addViewDimension(TechDraw::DrawViewDimension *dim) +QGIView * QGSPage::addViewDimension(TechDraw::DrawViewDimension *dimFeat) { auto dimGroup( new QGIViewDimension ); addItem(dimGroup); - dimGroup->setViewPartFeature(dim); - dimGroup->dvDimension = dim; + dimGroup->setViewPartFeature(dimFeat); // Find if it belongs to a parent QGIView *parent = nullptr; parent = findParent(dimGroup); if(parent) { - addDimToParent(dimGroup,parent); + addDimToParent(dimGroup, parent); } return dimGroup; @@ -621,26 +610,26 @@ void QGSPage::addDimToParent(QGIViewDimension* dim, QGIView* parent) // Base::Console().Message("QGSP::addDimToParent()\n"); assert(dim); assert(parent); //blow up if we don't have Dimension or Parent - QPointF posRef(0.,0.); + QPointF posRef(0., 0.); QPointF mapPos = dim->mapToItem(parent, posRef); dim->moveBy(-mapPos.x(), -mapPos.y()); parent->addToGroup(dim); dim->setZValue(ZVALUE::DIMENSION); } -QGIView * QGSPage::addViewLeader(TechDraw::DrawLeaderLine *leader) +QGIView * QGSPage::addViewLeader(TechDraw::DrawLeaderLine *leaderFeat) { -// Base::Console().Message("QGSP::addViewLeader(%s)\n",leader->getNameInDocument()); +// Base::Console().Message("QGSP::addViewLeader(%s)\n", leader->getNameInDocument()); QGILeaderLine* leaderGroup = new QGILeaderLine(); addItem(leaderGroup); - leaderGroup->setLeaderFeature(leader); + leaderGroup->setLeaderFeature(leaderFeat); QGIView *parent = nullptr; parent = findParent(leaderGroup); if(parent) { - addLeaderToParent(leaderGroup,parent); + addLeaderToParent(leaderGroup, parent); } leaderGroup->updateView(true); @@ -655,11 +644,11 @@ void QGSPage::addLeaderToParent(QGILeaderLine* lead, QGIView* parent) lead->setZValue(ZVALUE::DIMENSION); } -QGIView * QGSPage::addRichAnno(TechDraw::DrawRichAnno* anno) +QGIView * QGSPage::addRichAnno(TechDraw::DrawRichAnno* richFeat) { QGIRichAnno* annoGroup = new QGIRichAnno(); addItem(annoGroup); - annoGroup->setViewFeature(anno); + annoGroup->setViewFeature(richFeat); QGIView *parent = findParent(annoGroup); if (parent != nullptr) { @@ -679,13 +668,13 @@ void QGSPage::addAnnoToParent(QGIRichAnno* anno, QGIView* parent) } -QGIView * QGSPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weld) +QGIView * QGSPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weldFeat) { // Base::Console().Message("QGSP::addWeldSymbol()\n"); QGIWeldSymbol* weldGroup = nullptr; TechDraw::DrawView* parentDV = nullptr; - - App::DocumentObject* parentObj = weld->Leader.getValue(); + + App::DocumentObject* parentObj = weldFeat->Leader.getValue(); if (parentObj) { parentDV = dynamic_cast(parentObj); } else { @@ -696,8 +685,8 @@ QGIView * QGSPage::addWeldSymbol(TechDraw::DrawWeldSymbol* weld) QGILeaderLine* leadParent = dynamic_cast(parentQV); if (leadParent) { weldGroup = new QGIWeldSymbol(leadParent); - weldGroup->setFeature(weld); //for QGIWS - weldGroup->setViewFeature(weld); //for QGIV + weldGroup->setFeature(weldFeat); //for QGIWS + weldGroup->setViewFeature(weldFeat); //for QGIV weldGroup->updateView(true); } } @@ -714,7 +703,7 @@ void QGSPage::setDimensionGroups(void) QGIView* parent = findParent(item); if (parent) { QGIViewDimension* dim = dynamic_cast(item); - addDimToParent(dim,parent); + addDimToParent(dim, parent); } } } @@ -730,7 +719,7 @@ void QGSPage::setBalloonGroups(void) QGIView* parent = findParent(item); if (parent) { QGIViewBalloon* balloon = dynamic_cast(item); - addBalloonToParent(balloon,parent); + addBalloonToParent(balloon, parent); } } } @@ -749,7 +738,7 @@ void QGSPage::setLeaderGroups(void) QGIView* parent = findParent(item); if (parent) { QGILeaderLine* lead = dynamic_cast(item); - addLeaderToParent(lead,parent); + addLeaderToParent(lead, parent); } } } @@ -767,7 +756,7 @@ void QGSPage::setRichAnnoGroups(void) QGIView* parent = findParent(item); if (parent) { QGIRichAnno* anno = dynamic_cast(item); - addAnnoToParent(anno,parent); + addAnnoToParent(anno, parent); } } } @@ -917,7 +906,7 @@ void QGSPage::refreshViews() // Base::Console().Message("QGSP::refreshViews()\n"); QList list = items(); QList qgiv; - //find only QGIV's + //find only QGIV's for (auto q: list) { QString viewFamily = QString::fromUtf8("QGIV"); if (viewFamily == q->data(0).toString()) { @@ -1065,9 +1054,9 @@ void QGSPage::redrawAllViews() } //NOTE: this doesn't add missing views. see fixOrphans() -void QGSPage::redraw1View(TechDraw::DrawView* dv) +void QGSPage::redraw1View(TechDraw::DrawView* dView) { - std::string dvName = dv->getNameInDocument(); + std::string dvName = dView->getNameInDocument(); const std::vector &upviews = getViews(); for(std::vector::const_iterator it = upviews.begin(); it != upviews.end(); ++it) { std::string qgivName = (*it)->getViewName(); @@ -1151,14 +1140,14 @@ void QGSPage::saveSvg(QString filename) double width = Rez::guiX(page->getPageWidth()); double height = Rez::guiX(page->getPageHeight()); - QRectF sourceRect(0.0,-height,width,height); - QRectF targetRect(0.0,0.0,width,height); + QRectF sourceRect(0.0, -height, width, height); + QRectF targetRect(0.0, 0.0, width, height); Gui::Selection().clearSelection(); QPainter p; p.begin(&svgGen); - render(&p, targetRect,sourceRect); //note: scene render, not item render! + render(&p, targetRect, sourceRect); //note: scene render, not item render! p.end(); m_vpPage->setFrameState(saveState); @@ -1283,7 +1272,7 @@ void QGSPage::postProcessXml(QTemporaryFile& temporaryFile, QString fileName, QS // Time to save our product QFile outFile( fileName ); if( !outFile.open( QIODevice::WriteOnly | QIODevice::Text ) ) { - Base::Console().Error("QGSP::ppxml - failed to open file for writing: %s\n",qPrintable(fileName) ); + Base::Console().Error("QGSP::ppxml - failed to open file for writing: %s\n", qPrintable(fileName) ); } QTextStream stream( &outFile ); diff --git a/src/Mod/TechDraw/Gui/QGSPage.h b/src/Mod/TechDraw/Gui/QGSPage.h index a2788bb881..8c0c2d705e 100644 --- a/src/Mod/TechDraw/Gui/QGSPage.h +++ b/src/Mod/TechDraw/Gui/QGSPage.h @@ -38,6 +38,8 @@ class DocumentObject; namespace TechDraw { class DrawView; class DrawViewPart; +class DrawViewSection; +class DrawViewDetail; class DrawProjGroup; class DrawViewDimension; class DrawPage; @@ -70,32 +72,32 @@ class TechDrawGuiExport QGSPage : public QGraphicsScene Q_OBJECT public: - explicit QGSPage(ViewProviderPage *vp, QWidget *parent = nullptr); - ~QGSPage() override; + explicit QGSPage(ViewProviderPage *vpPage, QWidget *parent = nullptr); + ~QGSPage() = default; bool addView(const App::DocumentObject *obj); bool attachView(App::DocumentObject *obj); - QGIView * addViewDimension(TechDraw::DrawViewDimension *dim); - QGIView * addViewBalloon(TechDraw::DrawViewBalloon *balloon); - QGIView * addProjectionGroup(TechDraw::DrawProjGroup *view); - QGIView * addViewPart(TechDraw::DrawViewPart *part); - QGIView * addViewSection(TechDraw::DrawViewPart *part); - QGIView * addDrawView(TechDraw::DrawView *view); - QGIView * addDrawViewCollection(TechDraw::DrawViewCollection *view); - QGIView * addDrawViewAnnotation(TechDraw::DrawViewAnnotation *view); - QGIView * addDrawViewSymbol(TechDraw::DrawViewSymbol *view); - QGIView * addDrawViewClip(TechDraw::DrawViewClip *view); - QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *view); - QGIView * addDrawViewImage(TechDraw::DrawViewImage *view); - QGIView * addViewLeader(TechDraw::DrawLeaderLine* view); - QGIView * addRichAnno(TechDraw::DrawRichAnno* anno); - QGIView * addWeldSymbol(TechDraw::DrawWeldSymbol* weld); + QGIView * addViewDimension(TechDraw::DrawViewDimension *dimFeat); + QGIView * addViewBalloon(TechDraw::DrawViewBalloon *balloonFeat); + QGIView * addProjectionGroup(TechDraw::DrawProjGroup *projGroupFeat); + QGIView * addViewPart(TechDraw::DrawViewPart *partFeat); + QGIView * addViewSection(TechDraw::DrawViewSection *sectionFeat); + QGIView * addDrawView(TechDraw::DrawView *viewFeat); + QGIView * addDrawViewCollection(TechDraw::DrawViewCollection *collectionFeat); + QGIView * addDrawViewAnnotation(TechDraw::DrawViewAnnotation *annoFeat); + QGIView * addDrawViewSymbol(TechDraw::DrawViewSymbol *symbolFeat); + QGIView * addDrawViewClip(TechDraw::DrawViewClip *clipFeat); + QGIView * addDrawViewSpreadsheet(TechDraw::DrawViewSpreadsheet *sheetFeat); + QGIView * addDrawViewImage(TechDraw::DrawViewImage *imageFeat); + QGIView * addViewLeader(TechDraw::DrawLeaderLine* leaderFeat); + QGIView * addRichAnno(TechDraw::DrawRichAnno* richFeat); + QGIView * addWeldSymbol(TechDraw::DrawWeldSymbol* weldFeat); - void addChildrenToPage(void); + void addChildrenToPage(); void fixOrphans(bool force = false); - void redrawAllViews(void); - void redraw1View(TechDraw::DrawView* dv); + void redrawAllViews(); + void redraw1View(TechDraw::DrawView* dView); QGIView* findQViewForDocObj(App::DocumentObject *obj) const; QGIView* getQGIVByName(std::string name); @@ -117,10 +119,10 @@ public: int removeQViewByName(const char* name); void removeQViewFromScene(QGIView *view); - void setPageTemplate(TechDraw::DrawTemplate *pageTemplate); + void setPageTemplate(TechDraw::DrawTemplate *templateFeat); QGITemplate * getTemplate() const; void removeTemplate(); - void matchSceneRectToTemplate(void); + void matchSceneRectToTemplate(); void attachTemplate(TechDraw::DrawTemplate *obj); void updateTemplate(bool force = false); QPointF getTemplateCenter(); @@ -132,26 +134,19 @@ public: /// Renders the page to SVG with filename. void saveSvg(QString filename); - void postProcessXml(QTemporaryFile& tempFile, QString filename, QString pagename); + void postProcessXml(QTemporaryFile& temporaryFile, QString filename, QString pagename); - void setDimensionGroups(void); - void setBalloonGroups(void); - void setLeaderGroups(void); - void setRichAnnoGroups(void); - -public Q_SLOTS: + void setDimensionGroups(); + void setBalloonGroups(); + void setLeaderGroups(); + void setRichAnnoGroups(); protected: - static QColor SelectColor; - static QColor PreselectColor; QColor getBackgroundColor(); - - - QGITemplate *pageTemplate; - bool orphanExists(const char *viewName, const std::vector &list); private: + QGITemplate *pageTemplate; ViewProviderPage *m_vpPage; QPageLayout::Orientation m_orientation; @@ -160,6 +155,6 @@ private: }; -} // namespace +} // namespace #endif // TECHDRAWGUI_QGSCENE_H diff --git a/src/Mod/TechDraw/Gui/QGTracker.cpp b/src/Mod/TechDraw/Gui/QGTracker.cpp index 74cc50a918..6c53c86a35 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.cpp +++ b/src/Mod/TechDraw/Gui/QGTracker.cpp @@ -56,7 +56,7 @@ using namespace TechDrawGui; QGTracker::QGTracker(QGSPage* inScene, TrackerMode m): m_sleep(false), m_qgParent(nullptr), - m_lastClick(QPointF(FLT_MAX,FLT_MAX)) + m_lastClick(QPointF(FLT_MAX, FLT_MAX)) { setTrackerMode(m); if (inScene) { @@ -69,11 +69,11 @@ QGTracker::QGTracker(QGSPage* inScene, TrackerMode m): setFlag(QGraphicsItem::ItemIsSelectable, true); setFlag(QGraphicsItem::ItemIsMovable, false); setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); setFlag(QGraphicsItem::ItemIsFocusable, true); setAcceptHoverEvents(true); setZValue(ZVALUE::TRACKER); - setPos(0.0,0.0); + setPos(0.0, 0.0); QColor tColor = getTrackerColor(); QColor tailColor(Qt::blue); @@ -92,7 +92,7 @@ QGTracker::QGTracker(QGSPage* inScene, TrackerMode m): m_track->setPen(m_trackPen); m_track->setBrush(QBrush(Qt::NoBrush)); m_track->setFlag(QGraphicsItem::ItemSendsScenePositionChanges, true); - m_track->setFlag(QGraphicsItem::ItemSendsGeometryChanges,true); + m_track->setFlag(QGraphicsItem::ItemSendsGeometryChanges, true); m_track->setFocusProxy(this); setHandlesChildEvents(true); @@ -107,15 +107,15 @@ QGTracker::~QGTracker() } void QGTracker::mousePressEvent(QGraphicsSceneMouseEvent *event) -{ +{ QPointF myScenePos = event->scenePos(); if (!m_sleep) { double someLimit = Rez::guiX(10.0); QPointF manhat = myScenePos - m_lastClick; -// Base::Console().Message("QGT::mousePressEvent - scenePos: (%.3f, %.3f) lastClick:(%.3f,%.3f)\n", -// myScenePos.x(), myScenePos.y(), m_lastClick.x(),m_lastClick.y()); +// Base::Console().Message("QGT::mousePressEvent - scenePos: (%.3f, %.3f) lastClick:(%.3f, %.3f)\n", +// myScenePos.x(), myScenePos.y(), m_lastClick.x(), m_lastClick.y()); // Base::Console().Message("QGT::mousePressEvent - manhat(%.3f, %.3f) mLength: %.3f\n", -// manhat.x(),manhat.y(), manhat.manhattanLength()); +// manhat.x(), manhat.y(), manhat.manhattanLength()); if (manhat.manhattanLength() < someLimit) { // Base::Console().Message("QGT::mousePressEvent - too close to last click\n"); } else { @@ -193,7 +193,7 @@ QPointF QGTracker::snapToAngle(QPointF dumbPt) double angleIncr = M_PI / 8.0; //15* //mirror last clicked point and event point to get sensible coords QPointF last(m_points.back().x(), -m_points.back().y()); - QPointF pt(dumbPt.x(),-dumbPt.y()); + QPointF pt(dumbPt.x(), -dumbPt.y()); //let's do math with sensible coord system. QPointF qVec = last - pt; //vec from end of track to end of tail @@ -215,7 +215,7 @@ QPointF QGTracker::snapToAngle(QPointF dumbPt) actual = low; } - double vecLen = sqrt(pow(qVec.x(),2) + pow(qVec.y(),2)); + double vecLen = sqrt(pow(qVec.x(), 2) + pow(qVec.y(), 2)); double xPart = vecLen * cos(actual) * -1.0; //actual is not in Qt coords double yPart = vecLen * sin(actual) * -1.0; result = QPointF(last.x() + xPart, (-last.y()) + yPart); //back to silly qt coords! @@ -224,7 +224,7 @@ QPointF QGTracker::snapToAngle(QPointF dumbPt) } //mouse event reactions -void QGTracker::onMousePress(QPointF pos) +void QGTracker::onMousePress(QPointF pos) { // Base::Console().Message("QGT::onMousePress(%s)\n", TechDraw::DrawUtil::formatVector(pos).c_str()); m_points.push_back(pos); @@ -247,7 +247,7 @@ void QGTracker::onMousePress(QPointF pos) // setPoint(m_points); break; } - } else if (m_points.size() == 1) { //first point selected + } else if (m_points.size() == 1) { //first point selected //just return pos to caller getPickedQGIV(pos); setCursor(Qt::CrossCursor); //why cross?? @@ -265,9 +265,9 @@ void QGTracker::onMousePress(QPointF pos) } } -void QGTracker::onMouseMove(QPointF pos) +void QGTracker::onMouseMove(QPointF pos) { - //check distance moved? + //check distance moved? TrackerMode m = getTrackerMode(); switch (m) { case TrackerMode::None: @@ -287,7 +287,7 @@ void QGTracker::onMouseMove(QPointF pos) } } -void QGTracker::onDoubleClick(QPointF pos) +void QGTracker::onDoubleClick(QPointF pos) { // Base::Console().Message("QGTracker::onDoubleClick()\n"); Q_UNUSED(pos); @@ -298,14 +298,14 @@ void QGTracker::onDoubleClick(QPointF pos) terminateDrawing(); } -void QGTracker::getPickedQGIV(QPointF pos) +void QGTracker::getPickedQGIV(QPointF pos) { setVisible(false); m_qgParent = nullptr; QList views = scene()->views(); QGraphicsView* ourView = views.front(); //only 1 view / 1 scene / 1 mdipage QTransform viewXForm = ourView->transform(); - QGraphicsItem* pickedItem = scene()->itemAt(pos,viewXForm); + QGraphicsItem* pickedItem = scene()->itemAt(pos, viewXForm); if (pickedItem) { QGraphicsItem* topItem = pickedItem->topLevelItem(); if (topItem != pickedItem) { @@ -331,9 +331,9 @@ QPainterPath QGTracker::shape() const result.addRect(boundingRect()); return result; } - -//*************** -//actual art routines + +//*************** +//actual art routines void QGTracker::drawTrackLine(QPointF pos) { // Base::Console().Message("QGTracker::drawTrackLine()\n"); @@ -355,7 +355,7 @@ void QGTracker::drawTrackSquare(QPointF pos) QPainterPath tail; if (!m_points.empty()) { m_segBegin = m_points.front(); //sb front? 1st point picked?? - QRectF rect(m_segBegin,m_segEnd); + QRectF rect(m_segBegin, m_segEnd); tail.addRect(rect); m_track->setPath(tail); m_track->show(); @@ -368,9 +368,9 @@ void QGTracker::drawTrackCircle(QPointF pos) QPointF circum = pos; QPainterPath tail; if (!m_points.empty()) { - QPointF center = m_points.front(); //not nec (0,0); + QPointF center = m_points.front(); //not nec (0, 0); QPointF ray = circum - center; - double radius = sqrt(pow(ray.x(),2.0) + pow(ray.y(),2.0)); + double radius = sqrt(pow(ray.x(), 2.0) + pow(ray.y(), 2.0)); tail.addEllipse(center, radius, radius); m_track->setPath(tail); } @@ -410,7 +410,7 @@ void QGTracker::setSquareFromPoints(std::vector pts) QPainterPath newPath; QPointF start = pts.front(); QPointF end = pts.back(); - QRectF rect(start,end); + QRectF rect(start, end); newPath.addRect(rect); setPath(newPath); setPrettyNormal(); @@ -428,7 +428,7 @@ void QGTracker::setCircleFromPoints(std::vector pts) QPointF center = pts.front(); QPointF circum = pts.back(); QPointF ray = circum - center; - double radius = sqrt(pow(ray.x(),2.0) + pow(ray.y(),2.0)); + double radius = sqrt(pow(ray.x(), 2.0) + pow(ray.y(), 2.0)); newPath.addEllipse(center, radius, radius); setPath(newPath); setPrettyNormal(); @@ -454,7 +454,7 @@ std::vector QGTracker::convertPoints() { std::vector result; for (auto& p: m_points) { - Base::Vector3d v(p.x(),p.y(),0.0); + Base::Vector3d v(p.x(), p.y(), 0.0); result.push_back(v); } return result; diff --git a/src/Mod/TechDraw/Gui/QGTracker.h b/src/Mod/TechDraw/Gui/QGTracker.h index f5bc2115ad..a543828e19 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.h +++ b/src/Mod/TechDraw/Gui/QGTracker.h @@ -44,6 +44,14 @@ namespace TechDrawGui class QGSPage; class QGIView; +//TODO: make this a proper enum +static constexpr int TRACKERPICK(0); +static constexpr int TRACKEREDIT(1); +static constexpr int TRACKERCANCEL(2); +static constexpr int TRACKERCANCELEDIT(3); +static constexpr int TRACKERFINISHED(4); +static constexpr int TRACKERSAVE(5); + class TechDrawGuiExport QGTracker : public QObject, public QGIPrimPath { Q_OBJECT diff --git a/src/Mod/TechDraw/Gui/QGVNavStyle.cpp b/src/Mod/TechDraw/Gui/QGVNavStyle.cpp index d3606b933f..6054b2fd76 100644 --- a/src/Mod/TechDraw/Gui/QGVNavStyle.cpp +++ b/src/Mod/TechDraw/Gui/QGVNavStyle.cpp @@ -63,16 +63,16 @@ void QGVNavStyle::initialize() this->shiftdown = false; this->altdown = false; this->invertZoom = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/View")->GetBool("InvertZoom",true); + ("User parameter:BaseApp/Preferences/View")->GetBool("InvertZoom", true); this->zoomAtCursor = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/View")->GetBool("ZoomAtCursor",true); + ("User parameter:BaseApp/Preferences/View")->GetBool("ZoomAtCursor", true); this->zoomStep = App::GetApplication().GetParameterGroupByPath - ("User parameter:BaseApp/Preferences/View")->GetFloat("ZoomStep",0.2f); + ("User parameter:BaseApp/Preferences/View")->GetFloat("ZoomStep", 0.2f); Base::Reference hGrp = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - m_reversePan = hGrp->GetInt("KbPan",1); - m_reverseScroll = hGrp->GetInt("KbScroll",1); + m_reversePan = hGrp->GetInt("KbPan", 1); + m_reverseScroll = hGrp->GetInt("KbScroll", 1); panningActive = false; zoomingActive = false; @@ -114,7 +114,7 @@ void QGVNavStyle::handleKeyPressEvent(QKeyEvent *event) { if(event->modifiers().testFlag(Qt::ControlModifier)) { switch(event->key()) { - case Qt::Key_Plus: { + case Qt::Key_Plus: { zoom(1.0 + zoomStep); event->accept(); break; diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 4d3efd7d6e..8d4312199d 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -154,9 +154,9 @@ static unsigned char pan_bitmap[PAN_BYTES] = static unsigned char pan_mask_bitmap[PAN_BYTES] = { - 0xc0,0x03,0xe0,0x03,0xe0,0x07,0xf0,0x0f,0xe8,0x17,0xdc,0x3b,0xff,0xff,0xff, - 0xff,0xff,0xff,0xff,0xff,0xdc,0x3b,0xe8,0x17,0xf0,0x0f,0xe0,0x07,0xc0,0x03, - 0xc0,0x03 + 0xc0, 0x03, 0xe0, 0x03, 0xe0, 0x07, 0xf0, 0x0f, 0xe8, 0x17, 0xdc, 0x3b, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0xff, 0xdc, 0x3b, 0xe8, 0x17, 0xf0, 0x0f, 0xe0, 0x07, 0xc0, 0x03, + 0xc0, 0x03 }; /*** zoom-style cursor ******/ @@ -176,9 +176,9 @@ static unsigned char zoom_bitmap[ZOOM_BYTES] = static unsigned char zoom_mask_bitmap[ZOOM_BYTES] = { - 0x00,0x0f,0x80,0x1f,0xc0,0x3f,0xe0,0x7f,0xf0,0xff,0xf0,0xff,0xf0,0xff,0x00, - 0x0f,0x00,0x0f,0xf0,0xff,0xf0,0xff,0xf0,0xff,0xe0,0x7f,0xc0,0x3f,0x80,0x1f, - 0x00,0x0f + 0x00, 0x0f, 0x80, 0x1f, 0xc0, 0x3f, 0xe0, 0x7f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0x00, + 0x0f, 0x00, 0x0f, 0xf0, 0xff, 0xf0, 0xff, 0xf0, 0xff, 0xe0, 0x7f, 0xc0, 0x3f, 0x80, 0x1f, + 0x00, 0x0f }; using namespace Gui; using namespace TechDraw; @@ -197,24 +197,24 @@ public: void init() { page->m_atCursor = hGrp->GetBool("ZoomAtCursor", 1l); page->m_invertZoom = hGrp->GetBool("InvertZoom", 0l); - page->m_zoomIncrement = hGrp->GetFloat("ZoomStep",0.02); + page->m_zoomIncrement = hGrp->GetFloat("ZoomStep", 0.02); auto hTDPref = App::GetApplication().GetUserParameter() .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/General"); - page->m_reversePan = hTDPref->GetInt("KbPan",1); - page->m_reverseScroll = hTDPref->GetInt("KbScroll",1); + page->m_reversePan = hTDPref->GetInt("KbPan", 1); + page->m_reverseScroll = hTDPref->GetInt("KbScroll", 1); } /// Observer message from the ParameterGrp - void OnChange(ParameterGrp::SubjectType &rCaller,ParameterGrp::MessageType Reason) override { + void OnChange(ParameterGrp::SubjectType &rCaller, ParameterGrp::MessageType Reason) override { const ParameterGrp& rGrp = static_cast(rCaller); - if (strcmp(Reason,"NavigationStyle") == 0) { - std::string model = rGrp.GetASCII("NavigationStyle",CADNavigationStyle::getClassTypeId().getName()); + if (strcmp(Reason, "NavigationStyle") == 0) { + std::string model = rGrp.GetASCII("NavigationStyle", CADNavigationStyle::getClassTypeId().getName()); page->setNavigationStyle(model); - } else if (strcmp(Reason,"InvertZoom") == 0) { + } else if (strcmp(Reason, "InvertZoom") == 0) { page->m_invertZoom = rGrp.GetBool("InvertZoom", true); - } else if (strcmp(Reason,"ZoomStep") == 0) { + } else if (strcmp(Reason, "ZoomStep") == 0) { page->m_zoomIncrement = rGrp.GetFloat("ZoomStep", 0.0f); - } else if (strcmp(Reason,"ZoomAtCursor") == 0) { + } else if (strcmp(Reason, "ZoomAtCursor") == 0) { page->m_atCursor = rGrp.GetBool("ZoomAtCursor", true); if (page->m_atCursor) { page->setResizeAnchor(QGVPage::AnchorUnderMouse); @@ -232,24 +232,24 @@ public: } }; -QGVPage::QGVPage(ViewProviderPage *vp, QGSPage* s, QWidget *parent) +QGVPage::QGVPage(ViewProviderPage *vpPage, QGSPage* scenePage, QWidget *parent) : QGraphicsView(parent), m_renderer(Native), drawBkg(true), m_vpPage(nullptr), - m_scene(s), + m_scene(scenePage), balloonPlacing(false), panningActive(false), m_showGrid(false), m_navStyle(nullptr), d(new Private(this)) { - assert(vp); - m_vpPage = vp; - const char* name = vp->getDrawPage()->getNameInDocument(); + assert(vpPage); + m_vpPage = vpPage; + const char* name = vpPage->getDrawPage()->getNameInDocument(); setObjectName(QString::fromLocal8Bit(name)); - setScene(s); + setScene(scenePage); setMouseTracking(true); viewport()->setMouseTracking(true); @@ -350,7 +350,7 @@ void QGVPage::setNavigationStyle(std::string navParm) void QGVPage::startBalloonPlacing() { balloonPlacing = true; -#if QT_VERSION >= QT_VERSION_CHECK(5,15,0) +#if QT_VERSION >= QT_VERSION_CHECK(5, 15, 0) activateCursor(QCursor(balloonCursor->pixmap(Qt::ReturnByValue), balloonHotspot.x(), balloonHotspot.y())); #else activateCursor(QCursor(*balloonCursor->pixmap(), balloonHotspot.x(), balloonHotspot.y())); @@ -364,7 +364,7 @@ void QGVPage::cancelBalloonPlacing() resetCursor(); } -void QGVPage::drawBackground(QPainter *p, const QRectF &) +void QGVPage::drawBackground(QPainter *painter, const QRectF &) { //Note: Background is not part of scene() if(!drawBkg) @@ -379,11 +379,11 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &) return; } - p->save(); - p->resetTransform(); + painter->save(); + painter->resetTransform(); - p->setBrush(*bkgBrush); - p->drawRect(viewport()->rect().adjusted(-2,-2,2,2)); //just bigger than viewport to prevent artifacts + painter->setBrush(*bkgBrush); + painter->drawRect(viewport()->rect().adjusted(-2, -2, 2,2)); //just bigger than viewport to prevent artifacts // Default to A3 landscape, though this is currently relevant // only for opening corrupt docs, etc. @@ -400,11 +400,11 @@ void QGVPage::drawBackground(QPainter *p, const QRectF &) QPolygon poly = mapFromScene(paperRect); QBrush pageBrush(Qt::white); - p->setBrush(pageBrush); + painter->setBrush(pageBrush); - p->drawRect(poly.boundingRect()); + painter->drawRect(poly.boundingRect()); - p->restore(); + painter->restore(); } void QGVPage::setRenderer(RendererType type) @@ -502,7 +502,7 @@ void QGVPage::focusOutEvent(QFocusEvent *event) { m_navStyle->handleFocusOutEvent(event); } -void QGVPage::kbPanScroll(int xMove, int yMove) +void QGVPage::kbPanScroll(int xMove, int yMove) { if (xMove != 0) { QScrollBar* hsb = horizontalScrollBar(); diff --git a/src/Mod/TechDraw/Gui/QGVPage.h b/src/Mod/TechDraw/Gui/QGVPage.h index d5b29e1d04..b1a0459291 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.h +++ b/src/Mod/TechDraw/Gui/QGVPage.h @@ -77,11 +77,11 @@ class TechDrawGuiExport QGVPage : public QGraphicsView public: enum RendererType { Native, OpenGL, Image }; - QGVPage(ViewProviderPage *vp, QGSPage* s, QWidget *parent = nullptr); - ~QGVPage() override; + QGVPage(ViewProviderPage *vpPage, QGSPage* scenePage, QWidget *parent = nullptr); + ~QGVPage(); void setRenderer(RendererType type = Native); - void drawBackground(QPainter *p, const QRectF &rect) override; + void drawBackground(QPainter *painter, const QRectF &rect) override; QGSPage* getScene() {return m_scene; } @@ -96,15 +96,15 @@ public: void showGrid(bool state) {m_showGrid = state;} void updateViewport() {viewport()->repaint();} - bool isBalloonPlacing() {return balloonPlacing; } - void setBalloonPlacing(bool s) {balloonPlacing = s;} + bool isBalloonPlacing() const {return balloonPlacing; } + void setBalloonPlacing(bool isPlacing) {balloonPlacing = isPlacing;} - QLabel* getBalloonCursor() {return balloonCursor;} - void setBalloonCursor(QLabel* l) {balloonCursor = l;} + QLabel* getBalloonCursor() const {return balloonCursor;} + void setBalloonCursor(QLabel* label) {balloonCursor = label;} void kbPanScroll(int xMove = 1, int yMove = 1); - QPointF getBalloonCursorPos() {return balloonCursorPos;} - void setBalloonCursorPos(QPoint p) { balloonCursorPos = p;} + QPointF getBalloonCursorPos() const {return balloonCursorPos;} + void setBalloonCursorPos(QPoint pos) { balloonCursorPos = pos;} void activateCursor(QCursor cursor); void resetCursor(); @@ -113,7 +113,7 @@ public: void pseudoContextEvent(); - void centerOnPage(void); + void centerOnPage(); public Q_SLOTS: void setHighQualityAntialiasing(bool highQualityAntialiasing); @@ -131,15 +131,13 @@ protected: void keyReleaseEvent(QKeyEvent *event) override; void contextMenuEvent(QContextMenuEvent *event) override; - static QColor SelectColor; - static QColor PreselectColor; QColor getBackgroundColor(); double getDevicePixelRatio() const; QPixmap prepareCursorPixmap(const char *iconName, QPoint &hotspot); void drawForeground(QPainter *painter, const QRectF &rect) override; - + std::string getNavStyleParameter(); Base::Type getStyleType(std::string model); @@ -155,7 +153,7 @@ private: QBrush* bkgBrush; QImage m_image; ViewProviderPage *m_vpPage; - + bool m_atCursor; bool m_invertZoom; double m_zoomIncrement; @@ -186,6 +184,6 @@ private: QContextMenuEvent* m_saveContextEvent; }; -} // namespace +} // namespace #endif // TECHDRAWGUI_QGVIEW_H diff --git a/src/Mod/TechDraw/Gui/Rez.cpp b/src/Mod/TechDraw/Gui/Rez.cpp index 21ab1eb63f..49f54fb5d8 100644 --- a/src/Mod/TechDraw/Gui/Rez.cpp +++ b/src/Mod/TechDraw/Gui/Rez.cpp @@ -57,7 +57,7 @@ double Rez::guiX(double x) Base::Vector3d Rez::guiX(Base::Vector3d v) { - Base::Vector3d result(guiX(v.x),guiX(v.y),guiX(v.z)); + Base::Vector3d result(guiX(v.x), guiX(v.y), guiX(v.z)); return result; } @@ -80,7 +80,7 @@ double Rez::appX(double x) Base::Vector3d Rez::appX(Base::Vector3d v) { - Base::Vector3d result(appX(v.x),appX(v.y),appX(v.z)); + Base::Vector3d result(appX(v.x), appX(v.y), appX(v.z)); return result; } @@ -101,7 +101,7 @@ QPointF Rez::guiPt(QPointF p) QPointF Rez::appPt(QPointF p) { - QPointF result(appX(p.x()),appX(p.y())); + QPointF result(appX(p.x()), appX(p.y())); return result; } @@ -116,13 +116,13 @@ QRectF Rez::guiRect(QRectF r) QSize Rez::guiSize(QSize s) { - QSize result((int)guiX(s.width()),(int)guiX(s.height())); + QSize result((int)guiX(s.width()), (int)guiX(s.height())); return result; } QSize Rez::appSize(QSize s) { - QSize result((int)appX(s.width()),(int)appX(s.height())); + QSize result((int)appX(s.width()), (int)appX(s.height())); return result; } diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.cpp b/src/Mod/TechDraw/Gui/TaskActiveView.cpp index f9ac4b84aa..41d2a41f6d 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.cpp +++ b/src/Mod/TechDraw/Gui/TaskActiveView.cpp @@ -121,9 +121,9 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView() std::string pageName = m_pageFeat->getNameInDocument(); - Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')", - symbolType.c_str(),symbolName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)", + Command::doCommand(Command::Doc, "App.activeDocument().addObject('%s', '%s')", + symbolType.c_str(), symbolName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", pageName.c_str(), symbolName.c_str()); App::Document* appDoc = m_pageFeat->getDocument(); @@ -146,12 +146,12 @@ TechDraw::DrawViewSymbol* TaskActiveView::createActiveView() ui->qsbWeight->rawValue(), ui->qsbBorder->rawValue(), ui->cbMode->currentIndex()); - Command::doCommand(Command::Doc,"f = open(\"%s\",'r')",(const char*)fileSpec.c_str()); - Command::doCommand(Command::Doc,"svg = f.read()"); -// Command::doCommand(Command::Doc,"print('length of svg: {}'.format(len(svg)))"); + Command::doCommand(Command::Doc, "f = open(\"%s\", 'r')", (const char*)fileSpec.c_str()); + Command::doCommand(Command::Doc, "svg = f.read()"); +// Command::doCommand(Command::Doc, "print('length of svg: {}'.format(len(svg)))"); - Command::doCommand(Command::Doc,"f.close()"); - Command::doCommand(Command::Doc,"App.activeDocument().%s.Symbol = svg",symbolName.c_str()); + Command::doCommand(Command::Doc, "f.close()"); + Command::doCommand(Command::Doc, "App.activeDocument().%s.Symbol = svg", symbolName.c_str()); App::DocumentObject* newObj = m_pageFeat->getDocument()->getObject(symbolName.c_str()); TechDraw::DrawViewSymbol* newSym = dynamic_cast(newObj); @@ -189,7 +189,7 @@ bool TaskActiveView::accept() Gui::Command::updateActive(); Gui::Command::commitCommand(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -199,8 +199,8 @@ bool TaskActiveView::reject() // Base::Console().Message("TAV::reject()\n"); //nothing to remove. - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } diff --git a/src/Mod/TechDraw/Gui/TaskActiveView.h b/src/Mod/TechDraw/Gui/TaskActiveView.h index bd746497f9..8c38c95a8e 100644 --- a/src/Mod/TechDraw/Gui/TaskActiveView.h +++ b/src/Mod/TechDraw/Gui/TaskActiveView.h @@ -64,8 +64,6 @@ public: QPushButton* btnCancel); void enableTaskButtons(bool b); -protected Q_SLOTS: - protected: void changeEvent(QEvent *e); diff --git a/src/Mod/TechDraw/Gui/TaskBalloon.cpp b/src/Mod/TechDraw/Gui/TaskBalloon.cpp index c42de7f8c8..bf303cf4a1 100644 --- a/src/Mod/TechDraw/Gui/TaskBalloon.cpp +++ b/src/Mod/TechDraw/Gui/TaskBalloon.cpp @@ -63,13 +63,13 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) ui->setupUi(this); - ui->qsbShapeScale->setValue(parent->dvBalloon->ShapeScale.getValue()); + ui->qsbShapeScale->setValue(parent->getBalloonFeat()->ShapeScale.getValue()); connect(ui->qsbShapeScale, SIGNAL(valueChanged(double)), this, SLOT(onShapeScaleChanged())); - ui->qsbSymbolScale->setValue(parent->dvBalloon->EndTypeScale.getValue()); + ui->qsbSymbolScale->setValue(parent->getBalloonFeat()->EndTypeScale.getValue()); connect(ui->qsbSymbolScale, SIGNAL(valueChanged(double)), this, SLOT(onEndSymbolScaleChanged())); - std::string value = parent->dvBalloon->Text.getValue(); + std::string value = parent->getBalloonFeat()->Text.getValue(); QString qs = QString::fromUtf8(value.data(), value.size()); ui->leText->setText(qs); ui->leText->selectAll(); @@ -77,11 +77,11 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) QTimer::singleShot(0, ui->leText, SLOT(setFocus())); DrawGuiUtil::loadArrowBox(ui->comboEndSymbol); - i = parent->dvBalloon->EndType.getValue(); + i = parent->getBalloonFeat()->EndType.getValue(); ui->comboEndSymbol->setCurrentIndex(i); connect(ui->comboEndSymbol, SIGNAL(currentIndexChanged(int)), this, SLOT(onEndSymbolChanged())); - i = parent->dvBalloon->BubbleShape.getValue(); + i = parent->getBalloonFeat()->BubbleShape.getValue(); ui->comboBubbleShape->setCurrentIndex(i); connect(ui->comboBubbleShape, SIGNAL(currentIndexChanged(int)), this, SLOT(onBubbleShapeChanged())); @@ -103,7 +103,7 @@ TaskBalloon::TaskBalloon(QGIViewBalloon *parent, ViewProviderBalloon *balloonVP) ui->qsbLineWidth->setValue(balloonVP->LineWidth.getValue()); } // new balloons have already the preferences BalloonKink length - ui->qsbKinkLength->setValue(parent->dvBalloon->KinkLength.getValue()); + ui->qsbKinkLength->setValue(parent->getBalloonFeat()->KinkLength.getValue()); connect(ui->qsbFontSize, SIGNAL(valueChanged(double)), this, SLOT(onFontsizeChanged())); connect(ui->comboLineVisible, SIGNAL(currentIndexChanged(int)), this, SLOT(onLineVisibleChanged())); @@ -146,7 +146,7 @@ void TaskBalloon::recomputeFeature() void TaskBalloon::onTextChanged() { - m_parent->dvBalloon->Text.setValue(ui->leText->text().toUtf8().constData()); + m_parent->getBalloonFeat()->Text.setValue(ui->leText->text().toUtf8().constData()); recomputeFeature(); } @@ -166,25 +166,25 @@ void TaskBalloon::onFontsizeChanged() void TaskBalloon::onBubbleShapeChanged() { - m_parent->dvBalloon->BubbleShape.setValue(ui->comboBubbleShape->currentIndex()); + m_parent->getBalloonFeat()->BubbleShape.setValue(ui->comboBubbleShape->currentIndex()); recomputeFeature(); } void TaskBalloon::onShapeScaleChanged() { - m_parent->dvBalloon->ShapeScale.setValue(ui->qsbShapeScale->value().getValue()); + m_parent->getBalloonFeat()->ShapeScale.setValue(ui->qsbShapeScale->value().getValue()); recomputeFeature(); } void TaskBalloon::onEndSymbolChanged() { - m_parent->dvBalloon->EndType.setValue(ui->comboEndSymbol->currentIndex()); + m_parent->getBalloonFeat()->EndType.setValue(ui->comboEndSymbol->currentIndex()); recomputeFeature(); } void TaskBalloon::onEndSymbolScaleChanged() { - m_parent->dvBalloon->EndTypeScale.setValue(ui->qsbSymbolScale->value().getValue()); + m_parent->getBalloonFeat()->EndTypeScale.setValue(ui->qsbSymbolScale->value().getValue()); recomputeFeature(); } @@ -202,7 +202,7 @@ void TaskBalloon::onLineWidthChanged() void TaskBalloon::onKinkLengthChanged() { - m_parent->dvBalloon->KinkLength.setValue(ui->qsbKinkLength->value().getValue()); + m_parent->getBalloonFeat()->KinkLength.setValue(ui->qsbKinkLength->value().getValue()); recomputeFeature(); } diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 8b547e3535..73c3ce22ea 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -56,13 +56,8 @@ #include #include "PreferencesGui.h" -#include "QGVPage.h" #include "QGIView.h" -#include "QGIPrimPath.h" -#include "MDIViewPage.h" -#include "ViewProviderPage.h" #include "ViewProviderViewPart.h" -#include "Rez.h" #include "TaskCenterLine.h" @@ -154,9 +149,9 @@ void TaskCenterLine::updateTask() { } -void TaskCenterLine::changeEvent(QEvent *e) +void TaskCenterLine::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -207,7 +202,7 @@ void TaskCenterLine::setUiPrimary() qAngle.setUnit(Base::Unit::Angle); ui->qsbRotate->setValue(qAngle); int precision = Base::UnitsApi::getDecimals(); - ui->qsbRotate->setDecimals(precision); + ui->qsbRotate->setDecimals(precision); } void TaskCenterLine::setUiEdit() @@ -247,7 +242,7 @@ void TaskCenterLine::setUiEdit() ui->qsbRotate->setValue(qAngle); int precision = Base::UnitsApi::getDecimals(); ui->qsbRotate->setDecimals(precision); - ui->qsbRotate->setValue(m_cl->m_rotate); + ui->qsbRotate->setValue(m_cl->m_rotate); } void TaskCenterLine::onOrientationChanged() @@ -418,10 +413,10 @@ void TaskCenterLine::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskCenterLine::enableTaskButtons(bool b) +void TaskCenterLine::enableTaskButtons(bool isEnabled) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(isEnabled); + m_btnCancel->setEnabled(isEnabled); } double TaskCenterLine::getCenterWidth() @@ -510,7 +505,7 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, bool editMode) : TaskDialog() { - widget = new TaskCenterLine(partFeat,page,subNames, editMode); + widget = new TaskCenterLine(partFeat, page, subNames, editMode); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_FaceCenterLine"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); @@ -524,7 +519,7 @@ TaskDlgCenterLine::TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, bool editMode) : TaskDialog() { - widget = new TaskCenterLine(partFeat,page, edgeName, editMode); + widget = new TaskCenterLine(partFeat, page, edgeName, editMode); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_FaceCenterLine"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.h b/src/Mod/TechDraw/Gui/TaskCenterLine.h index c2a50e154c..06cf54bb41 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.h +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.h @@ -28,6 +28,8 @@ #include #include +#include + //TODO: make this a proper enum #define TRACKERPICK 0 @@ -45,6 +47,7 @@ class DrawViewPart; class CosmeticEdge; class Face; class LineFormat; +class CenterLine; } namespace TechDrawGui @@ -62,32 +65,27 @@ class TaskCenterLine : public QWidget Q_OBJECT public: - TaskCenterLine(TechDraw::DrawViewPart* baseFeat, + TaskCenterLine(TechDraw::DrawViewPart* partFeat, TechDraw::DrawPage* page, std::vector subNames, bool editMode); - TaskCenterLine(TechDraw::DrawViewPart* baseFeat, + TaskCenterLine(TechDraw::DrawViewPart* partFeat, TechDraw::DrawPage* page, std::string edgeName, bool editMode); ~TaskCenterLine() override; -public Q_SLOTS: - -public: virtual bool accept(); virtual bool reject(); - virtual void setCreateMode(bool b) { m_createMode = b; } - virtual bool getCreateMode() { return m_createMode; } + virtual void setCreateMode(bool mode) { m_createMode = mode; } + virtual bool getCreateMode() const { return m_createMode; } void updateTask(); void saveButtons(QPushButton* btnOK, QPushButton* btnCancel); - void enableTaskButtons(bool b); - -protected Q_SLOTS: + void enableTaskButtons(bool isEnabled); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void setUiConnect(); void setUiPrimary(); void setUiEdit(); @@ -99,16 +97,6 @@ protected: Qt::PenStyle getCenterStyle(); double getExtendBy(); -private Q_SLOTS: - void onOrientationChanged(); - void onShiftHorizChanged(); - void onShiftVertChanged(); - void onRotationChanged(); - void onExtendChanged(); - void onColorChanged(); - void onWeightChanged(); - void onStyleChanged(); - private: std::unique_ptr ui; @@ -127,6 +115,17 @@ private: int m_type; int m_mode; bool m_editMode; + +private Q_SLOTS: + void onOrientationChanged(); + void onShiftHorizChanged(); + void onShiftVertChanged(); + void onRotationChanged(); + void onExtendChanged(); + void onColorChanged(); + void onWeightChanged(); + void onStyleChanged(); + }; class TaskDlgCenterLine : public Gui::TaskView::TaskDialog @@ -134,11 +133,11 @@ class TaskDlgCenterLine : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgCenterLine(TechDraw::DrawViewPart* baseFeat, + TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, TechDraw::DrawPage* page, std::vector subNames, bool editMode); - TaskDlgCenterLine(TechDraw::DrawViewPart* baseFeat, + TaskDlgCenterLine(TechDraw::DrawViewPart* partFeat, TechDraw::DrawPage* page, std::string edgeName, bool editMode); diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index 761093ee6c..099dd645c4 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -54,13 +54,10 @@ #include #include "QGSPage.h" -#include "QGVPage.h" #include "QGIView.h" -#include "QGIPrimPath.h" #include "MDIViewPage.h" #include "ViewProviderPage.h" #include "QGTracker.h" -#include "QGEPath.h" #include "Rez.h" #include "TaskCosVertex.h" @@ -101,10 +98,6 @@ TaskCosVertex::TaskCosVertex(TechDraw::DrawViewPart* baseFeat, m_trackerMode = QGTracker::TrackerMode::Point; } -TaskCosVertex::~TaskCosVertex() -{ -} - void TaskCosVertex::updateTask() { // blockUpdate = true; @@ -112,9 +105,9 @@ void TaskCosVertex::updateTask() // blockUpdate = false; } -void TaskCosVertex::changeEvent(QEvent* e) +void TaskCosVertex::changeEvent(QEvent* event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -162,9 +155,9 @@ void TaskCosVertex::addCosVertex(QPointF qPos) //********** Tracker routines ******************************************************************* -void TaskCosVertex::onTrackerClicked(bool b) +void TaskCosVertex::onTrackerClicked(bool clicked) { - Q_UNUSED(b); + Q_UNUSED(clicked); // Base::Console().Message("TCV::onTrackerClicked() m_pbTrackerState: %d\n", // m_pbTrackerState); @@ -246,7 +239,7 @@ void TaskCosVertex::onTrackerFinished(std::vector pts, QGIView* qgParen x += Rez::guiX(dpg->X.getValue()); y += Rez::guiX(dpg->Y.getValue()); } - //x,y are scene pos of dvp/dpgi + //x, y are scene pos of dvp/dpgi QPointF basePosScene(x, -y); //base position in scene coords QPointF displace = dragEnd - basePosScene; @@ -276,11 +269,11 @@ void TaskCosVertex::removeTracker() } } -void TaskCosVertex::setEditCursor(QCursor c) +void TaskCosVertex::setEditCursor(QCursor cursor) { if (m_baseFeat) { QGIView* qgivBase = m_vpp->getQGSPage()->findQViewForDocObj(m_baseFeat); - qgivBase->setCursor(c); + qgivBase->setCursor(cursor); } } @@ -302,10 +295,10 @@ void TaskCosVertex::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskCosVertex::enableTaskButtons(bool b) +void TaskCosVertex::enableTaskButtons(bool button) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(button); + m_btnCancel->setEnabled(button); } //****************************************************************************** diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.h b/src/Mod/TechDraw/Gui/TaskCosVertex.h index 3910a852f4..8700b4cac9 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.h +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.h @@ -30,13 +30,6 @@ #include "QGTracker.h" - -//TODO: make this a proper enum -#define TRACKERPICK 0 -#define TRACKEREDIT 1 -#define TRACKERCANCEL 2 -#define TRACKERCANCELEDIT 3 - namespace TechDraw { class DrawPage; @@ -65,32 +58,30 @@ class TaskCosVertex : public QWidget public: TaskCosVertex(TechDraw::DrawViewPart* baseFeat, TechDraw::DrawPage* page); - ~TaskCosVertex() override; + ~TaskCosVertex() = default; -public Q_SLOTS: - void onTrackerClicked(bool b); - void onTrackerFinished(std::vector pts, TechDrawGui::QGIView* qgParent); - -public: virtual bool accept(); virtual bool reject(); void updateTask(); void saveButtons(QPushButton* btnOK, QPushButton* btnCancel); - void enableTaskButtons(bool b); + void enableTaskButtons(bool button); + +public Q_SLOTS: + void onTrackerClicked(bool clicked); + void onTrackerFinished(std::vector pts, TechDrawGui::QGIView* qgParent); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void startTracker(); void removeTracker(); void abandonEditSession(); void addCosVertex(QPointF qPos); - void blockButtons(bool b); void setUiPrimary(); void updateUi(); - void setEditCursor(QCursor c); + void setEditCursor(QCursor cursor); QGIView* findParentQGIV(); @@ -99,7 +90,7 @@ private: bool blockUpdate; QGTracker* m_tracker; - + TechDraw::DrawViewPart* m_baseFeat; TechDraw::DrawPage* m_basePage; QGIView* m_qgParent; @@ -111,7 +102,7 @@ private: QPushButton* m_btnOK; QPushButton* m_btnCancel; - + int m_pbTrackerState; QPointF m_savePoint; bool pointFromTracker; @@ -138,7 +129,6 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp b/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp index 008e28b1bd..d8bf2d40b7 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp @@ -55,15 +55,6 @@ #include -#include "PreferencesGui.h" -#include "QGVPage.h" -#include "QGIView.h" -#include "QGIPrimPath.h" -#include "MDIViewPage.h" -#include "ViewProviderPage.h" -#include "ViewProviderViewPart.h" -#include "Rez.h" - #include "TaskCosmeticLine.h" using namespace Gui; @@ -268,7 +259,7 @@ bool TaskCosmeticLine::accept() Gui::Command::commitCommand(); } - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -276,7 +267,7 @@ bool TaskCosmeticLine::accept() bool TaskCosmeticLine::reject() { //there's nothing to do. - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } //////////////////////////////////////////////////////////////////////////////// diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticLine.h b/src/Mod/TechDraw/Gui/TaskCosmeticLine.h index 706848d0ea..121c5c46bd 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticLine.h +++ b/src/Mod/TechDraw/Gui/TaskCosmeticLine.h @@ -29,7 +29,6 @@ #include #include - namespace TechDraw { class DrawPage; @@ -55,22 +54,17 @@ class TaskCosmeticLine : public QWidget Q_OBJECT public: - TaskCosmeticLine(TechDraw::DrawViewPart* baseFeat, + TaskCosmeticLine(TechDraw::DrawViewPart* partFeat, std::vector points, std::vector is3d); - TaskCosmeticLine(TechDraw::DrawViewPart* baseFeat, + TaskCosmeticLine(TechDraw::DrawViewPart* partFeat, std::string edgeName); ~TaskCosmeticLine() override; -public Q_SLOTS: - -public: virtual bool accept(); virtual bool reject(); void updateTask(); -protected Q_SLOTS: - protected: void changeEvent(QEvent *e) override; @@ -86,7 +80,6 @@ private: TechDraw::DrawViewPart* m_partFeat; std::string m_edgeName; - //int m_edgeIndex; TechDraw::CosmeticEdge* m_ce; TechDraw::CosmeticEdge* m_saveCE; std::vector m_points; @@ -100,10 +93,10 @@ class TaskDlgCosmeticLine : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgCosmeticLine(TechDraw::DrawViewPart* baseFeat, + TaskDlgCosmeticLine(TechDraw::DrawViewPart* partFeat, std::vector points, std::vector is3d); - TaskDlgCosmeticLine(TechDraw::DrawViewPart* baseFeat, + TaskDlgCosmeticLine(TechDraw::DrawViewPart* partFeat, std::string edgeName); ~TaskDlgCosmeticLine() override; diff --git a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp index 42c0bd7614..c7006e36f4 100644 --- a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp +++ b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp @@ -75,7 +75,7 @@ TaskCustomizeFormat::TaskCustomizeFormat(App::DocumentObject * object) : selectedObject(object), isDimension(true), dimRawValue(0.0), - ui(new Ui_TaskCustomizeFormat) + ui(new Ui_TaskCustomizeFormat) { ui->setupUi(this); @@ -119,7 +119,7 @@ void TaskCustomizeFormat::setUiEdit() std::string balloonText = balloon->Text.getStrValue(); ui->leFormat->setText(Base::Tools::fromStdString(balloonText)); } - // GD&T + // GD&T connect(ui->pbA01, SIGNAL(clicked()), this, SLOT(onSymbolClicked())); connect(ui->pbA02, SIGNAL(clicked()), this, SLOT(onSymbolClicked())); connect(ui->pbA03, SIGNAL(clicked()), this, SLOT(onSymbolClicked())); @@ -204,7 +204,7 @@ void TaskCustomizeFormat::onFormatChanged() constexpr int size(80); char buffer[size]; std::string formatString = formatPreview.toUtf8().constData(); - auto usedSize = snprintf(buffer,size, formatString.c_str(),dimRawValue); + auto usedSize = snprintf(buffer, size, formatString.c_str(), dimRawValue); formatPreview = QString::fromUtf8(buffer, usedSize); } ui->lbShowPreview->setText(formatPreview); diff --git a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h index ef052ee3ec..b206392704 100644 --- a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h +++ b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h @@ -65,9 +65,6 @@ public: explicit TaskCustomizeFormat(App::DocumentObject * object); ~TaskCustomizeFormat() override; -public Q_SLOTS: - -public: virtual bool accept(); virtual bool reject(); void updateTask(); @@ -76,8 +73,6 @@ private Q_SLOTS: void onSymbolClicked(); void onFormatChanged(); -protected Q_SLOTS: - protected: void changeEvent(QEvent *e) override; diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index 101a7b06ee..546328bad3 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -56,12 +56,9 @@ #include "QGSPage.h" #include "QGIView.h" -#include "QGIPrimPath.h" #include "QGIGhostHighlight.h" -#include "MDIViewPage.h" #include "ViewProviderPage.h" #include "Rez.h" -#include "QGIViewPart.h" #include "TaskDetail.h" @@ -69,8 +66,8 @@ using namespace TechDrawGui; using namespace TechDraw; using namespace Gui; -#define CREATEMODE 0 -#define EDITMODE 1 +static constexpr int CREATEMODE(0); +static constexpr int EDITMODE(1); //creation constructor TaskDetail::TaskDetail(TechDraw::DrawViewPart* baseFeat): @@ -222,10 +219,6 @@ TaskDetail::TaskDetail(TechDraw::DrawViewDetail* detailFeat): this, SLOT(onHighlightMoved(QPointF))); } -TaskDetail::~TaskDetail() -{ -} - void TaskDetail::updateTask() { // blockUpdate = true; @@ -304,20 +297,20 @@ void TaskDetail::setUiFromFeat() } //update ui point fields after tracker finishes -void TaskDetail::updateUi(QPointF p) +void TaskDetail::updateUi(QPointF pos) { - ui->qsbX->setValue(p.x()); - ui->qsbY->setValue(- p.y()); + ui->qsbX->setValue(pos.x()); + ui->qsbY->setValue(- pos.y()); } -void TaskDetail::enableInputFields(bool b) +void TaskDetail::enableInputFields(bool isEnabled) { - ui->qsbX->setEnabled(b); - ui->qsbY->setEnabled(b); + ui->qsbX->setEnabled(isEnabled); + ui->qsbY->setEnabled(isEnabled); if (ui->cbScaleType->currentIndex() == 2) // only if custom scale - ui->qsbScale->setEnabled(b); - ui->qsbRadius->setEnabled(b); - ui->leReference->setEnabled(b); + ui->qsbScale->setEnabled(isEnabled); + ui->qsbRadius->setEnabled(isEnabled); + ui->leReference->setEnabled(isEnabled); } void TaskDetail::onXEdit() @@ -377,9 +370,9 @@ void TaskDetail::onReferenceEdit() updateDetail(); } -void TaskDetail::onDraggerClicked(bool b) +void TaskDetail::onDraggerClicked(bool clicked) { - Q_UNUSED(b); + Q_UNUSED(clicked); ui->pbDragger->setEnabled(false); enableInputFields(false); editByHighlight(); @@ -445,10 +438,10 @@ void TaskDetail::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskDetail::enableTaskButtons(bool b) +void TaskDetail::enableTaskButtons(bool button) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(button); + m_btnCancel->setEnabled(button); } //***** Feature create & edit stuff ******************************************* @@ -459,7 +452,7 @@ void TaskDetail::createDetail() m_detailName = m_doc->getUniqueObjectName("Detail"); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().addObject('TechDraw::DrawViewDetail','%s')", + Gui::Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawViewDetail', '%s')", m_detailName.c_str()); App::DocumentObject *docObj = m_doc->getObject(m_detailName.c_str()); TechDraw::DrawViewDetail* dvd = dynamic_cast(docObj); @@ -470,15 +463,15 @@ void TaskDetail::createDetail() dvd->Source.setValues(getBaseFeat()->Source.getValues()); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.BaseView = App.activeDocument().%s", - m_detailName.c_str(),m_baseName.c_str()); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.Direction = App.activeDocument().%s.Direction", - m_detailName.c_str(),m_baseName.c_str()); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.XDirection = App.activeDocument().%s.XDirection", - m_detailName.c_str(),m_baseName.c_str()); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.Scale = App.activeDocument().%s.Scale", - m_detailName.c_str(),m_baseName.c_str()); - Gui::Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)", + Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.BaseView = App.activeDocument().%s", + m_detailName.c_str(), m_baseName.c_str()); + Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.Direction = App.activeDocument().%s.Direction", + m_detailName.c_str(), m_baseName.c_str()); + Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.XDirection = App.activeDocument().%s.XDirection", + m_detailName.c_str(), m_baseName.c_str()); + Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.Scale = App.activeDocument().%s.Scale", + m_detailName.c_str(), m_baseName.c_str()); + Gui::Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", m_pageName.c_str(), m_detailName.c_str()); Gui::Command::updateActive(); @@ -588,7 +581,7 @@ DrawViewDetail* TaskDetail::getDetailFeat() return static_cast(detailObj); } } - + std::string msg = "TaskDetail - detail feature " + m_detailName + " not found \n"; @@ -610,7 +603,7 @@ bool TaskDetail::accept() m_ghost->hide(); getDetailFeat()->requestPaint(); getBaseFeat()->requestPaint(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -625,7 +618,7 @@ bool TaskDetail::reject() m_ghost->hide(); if (m_mode == CREATEMODE) { if (m_created) { - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')", + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')", m_detailName.c_str()); } } else { @@ -634,8 +627,8 @@ bool TaskDetail::reject() getBaseFeat()->requestPaint(); } - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } diff --git a/src/Mod/TechDraw/Gui/TaskDetail.h b/src/Mod/TechDraw/Gui/TaskDetail.h index 5b54e1fb13..6847a7be29 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.h +++ b/src/Mod/TechDraw/Gui/TaskDetail.h @@ -31,10 +31,11 @@ //TODO: make this a proper enum -#define TRACKERPICK 0 -#define TRACKEREDIT 1 -#define TRACKERCANCEL 2 -#define TRACKERCANCELEDIT 3 +static constexpr int TRACKERPICK(0); +static constexpr int TRACKEREDIT(1); +static constexpr int TRACKERCANCEL(2); +static constexpr int TRACKERCANCELEDIT(3); + namespace TechDraw { @@ -62,39 +63,38 @@ class TaskDetail : public QWidget public: explicit TaskDetail(TechDraw::DrawViewPart* baseFeat); explicit TaskDetail(TechDraw::DrawViewDetail* detailFeat); - ~TaskDetail() override; + ~TaskDetail() = default; -public Q_SLOTS: - void onDraggerClicked(bool b); - void onHighlightMoved(QPointF newPos); - void onXEdit(); - void onYEdit(); - void onRadiusEdit(); - void onScaleTypeEdit(); - void onScaleEdit(); - void onReferenceEdit(); - -public: virtual bool accept(); virtual bool reject(); void updateTask(); void saveButtons(QPushButton* btnOK, QPushButton* btnCancel); - void enableTaskButtons(bool b); - + void enableTaskButtons(bool button); + +public Q_SLOTS: + void onDraggerClicked(bool clicked); + void onHighlightMoved(QPointF dragEnd); + void onXEdit(); + void onYEdit(); + void onRadiusEdit(); + void onScaleTypeEdit(); + void onScaleEdit(); + void onReferenceEdit(); + protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void startDragger(); void createDetail(); void updateDetail(); - + void editByHighlight(); - void blockButtons(bool b); + void blockButtons(bool isBlocked); void setUiFromFeat(); - void updateUi(QPointF p); - void enableInputFields(bool b); + void updateUi(QPointF pos); + void enableInputFields(bool isEnabled); void saveDetailState(); void restoreDetailState(); @@ -144,7 +144,6 @@ public: explicit TaskDlgDetail(TechDraw::DrawViewDetail* detailFeat); ~TaskDlgDetail() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -154,15 +153,12 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); void modifyStandardButtons(QDialogButtonBox* box) override; -protected: - private: TaskDetail * widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskDimension.cpp b/src/Mod/TechDraw/Gui/TaskDimension.cpp index c9f212b4be..2afc1fdebd 100644 --- a/src/Mod/TechDraw/Gui/TaskDimension.cpp +++ b/src/Mod/TechDraw/Gui/TaskDimension.cpp @@ -66,23 +66,23 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di ui->setupUi(this); // Tolerancing - ui->cbTheoreticallyExact->setChecked(parent->dvDimension->TheoreticalExact.getValue()); + ui->cbTheoreticallyExact->setChecked(parent->getDimFeat()->TheoreticalExact.getValue()); connect(ui->cbTheoreticallyExact, SIGNAL(stateChanged(int)), this, SLOT(onTheoreticallyExactChanged())); // if TheoreticalExact disable tolerances - if (parent->dvDimension->TheoreticalExact.getValue()) { + if (parent->getDimFeat()->TheoreticalExact.getValue()) { ui->cbEqualTolerance->setDisabled(true); ui->qsbOvertolerance->setDisabled(true); ui->qsbUndertolerance->setDisabled(true); ui->leFormatSpecifierOverTolerance->setDisabled(true); ui->leFormatSpecifierUnderTolerance->setDisabled(true); } - ui->cbEqualTolerance->setChecked(parent->dvDimension->EqualTolerance.getValue()); + ui->cbEqualTolerance->setChecked(parent->getDimFeat()->EqualTolerance.getValue()); connect(ui->cbEqualTolerance, SIGNAL(stateChanged(int)), this, SLOT(onEqualToleranceChanged())); // if EqualTolerance overtolernace must not be negative - if (parent->dvDimension->EqualTolerance.getValue()) + if (parent->getDimFeat()->EqualTolerance.getValue()) ui->qsbOvertolerance->setMinimum(0.0); - if ((parent->dvDimension->Type.isValue("Angle")) || - (parent->dvDimension->Type.isValue("Angle3Pt"))) { + if ((parent->getDimFeat()->Type.isValue("Angle")) || + (parent->getDimFeat()->Type.isValue("Angle3Pt"))) { ui->qsbOvertolerance->setUnit(Base::Unit::Angle); ui->qsbUndertolerance->setUnit(Base::Unit::Angle); } @@ -90,8 +90,8 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di ui->qsbOvertolerance->setUnit(Base::Unit::Length); ui->qsbUndertolerance->setUnit(Base::Unit::Length); } - ui->qsbOvertolerance->setValue(parent->dvDimension->OverTolerance.getValue()); - ui->qsbUndertolerance->setValue(parent->dvDimension->UnderTolerance.getValue()); + ui->qsbOvertolerance->setValue(parent->getDimFeat()->OverTolerance.getValue()); + ui->qsbUndertolerance->setValue(parent->getDimFeat()->UnderTolerance.getValue()); connect(ui->qsbOvertolerance, SIGNAL(valueChanged(double)), this, SLOT(onOvertoleranceChanged())); connect(ui->qsbUndertolerance, SIGNAL(valueChanged(double)), this, SLOT(onUndertoleranceChanged())); // undertolerance is disabled when EqualTolerance is true @@ -101,21 +101,21 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di } // Formatting - std::string StringValue = parent->dvDimension->FormatSpec.getValue(); + std::string StringValue = parent->getDimFeat()->FormatSpec.getValue(); QString qs = QString::fromUtf8(StringValue.data(), StringValue.size()); ui->leFormatSpecifier->setText(qs); connect(ui->leFormatSpecifier, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierChanged())); - ui->cbArbitrary->setChecked(parent->dvDimension->Arbitrary.getValue()); + ui->cbArbitrary->setChecked(parent->getDimFeat()->Arbitrary.getValue()); connect(ui->cbArbitrary, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryChanged())); - StringValue = parent->dvDimension->FormatSpecOverTolerance.getValue(); + StringValue = parent->getDimFeat()->FormatSpecOverTolerance.getValue(); qs = QString::fromUtf8(StringValue.data(), StringValue.size()); ui->leFormatSpecifierOverTolerance->setText(qs); - StringValue = parent->dvDimension->FormatSpecUnderTolerance.getValue(); + StringValue = parent->getDimFeat()->FormatSpecUnderTolerance.getValue(); qs = QString::fromUtf8(StringValue.data(), StringValue.size()); ui->leFormatSpecifierUnderTolerance->setText(qs); connect(ui->leFormatSpecifierOverTolerance, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierOverToleranceChanged())); connect(ui->leFormatSpecifierUnderTolerance, SIGNAL(textChanged(QString)), this, SLOT(onFormatSpecifierUnderToleranceChanged())); - ui->cbArbitraryTolerances->setChecked(parent->dvDimension->ArbitraryTolerances.getValue()); + ui->cbArbitraryTolerances->setChecked(parent->getDimFeat()->ArbitraryTolerances.getValue()); connect(ui->cbArbitraryTolerances, SIGNAL(stateChanged(int)), this, SLOT(onArbitraryTolerancesChanged())); // Display Style @@ -133,11 +133,11 @@ TaskDimension::TaskDimension(QGIViewDimension *parent, ViewProviderDimension *di } // Lines - ui->rbOverride->setChecked(parent->dvDimension->AngleOverride.getValue()); + ui->rbOverride->setChecked(parent->getDimFeat()->AngleOverride.getValue()); connect(ui->rbOverride, SIGNAL(toggled(bool)), this, SLOT(onOverrideToggled())); - ui->dsbDimAngle->setValue(parent->dvDimension->LineAngle.getValue()); + ui->dsbDimAngle->setValue(parent->getDimFeat()->LineAngle.getValue()); connect(ui->dsbDimAngle, SIGNAL(valueChanged(double)), this, SLOT(onDimAngleChanged())); - ui->dsbExtAngle->setValue(parent->dvDimension->ExtensionAngle.getValue()); + ui->dsbExtAngle->setValue(parent->getDimFeat()->ExtensionAngle.getValue()); connect(ui->dsbExtAngle, SIGNAL(valueChanged(double)), this, SLOT(onExtAngleChanged())); connect(ui->pbDimUseDefault, SIGNAL(clicked()), this, SLOT(onDimUseDefaultClicked())); connect(ui->pbDimUseSelection, SIGNAL(clicked()), this, SLOT(onDimUseSelectionClicked())); @@ -183,7 +183,7 @@ void TaskDimension::recomputeFeature() void TaskDimension::onTheoreticallyExactChanged() { - m_parent->dvDimension->TheoreticalExact.setValue(ui->cbTheoreticallyExact->isChecked()); + m_parent->getDimFeat()->TheoreticalExact.setValue(ui->cbTheoreticallyExact->isChecked()); // if TheoreticalExact disable tolerances and set them to zero if (ui->cbTheoreticallyExact->isChecked()) { ui->qsbOvertolerance->setValue(0.0); @@ -211,7 +211,7 @@ void TaskDimension::onTheoreticallyExactChanged() void TaskDimension::onEqualToleranceChanged() { - m_parent->dvDimension->EqualTolerance.setValue(ui->cbEqualTolerance->isChecked()); + m_parent->getDimFeat()->EqualTolerance.setValue(ui->cbEqualTolerance->isChecked()); // if EqualTolerance set negated overtolerance for untertolerance // then also the OverTolerance must be positive if (ui->cbEqualTolerance->isChecked()) { @@ -236,7 +236,7 @@ void TaskDimension::onEqualToleranceChanged() void TaskDimension::onOvertoleranceChanged() { - m_parent->dvDimension->OverTolerance.setValue(ui->qsbOvertolerance->value().getValue()); + m_parent->getDimFeat()->OverTolerance.setValue(ui->qsbOvertolerance->value().getValue()); // if EqualTolerance set negated overtolerance for untertolerance if (ui->cbEqualTolerance->isChecked()) { ui->qsbUndertolerance->setValue(-1.0 * ui->qsbOvertolerance->value().getValue()); @@ -247,45 +247,45 @@ void TaskDimension::onOvertoleranceChanged() void TaskDimension::onUndertoleranceChanged() { - m_parent->dvDimension->UnderTolerance.setValue(ui->qsbUndertolerance->value().getValue()); + m_parent->getDimFeat()->UnderTolerance.setValue(ui->qsbUndertolerance->value().getValue()); recomputeFeature(); } void TaskDimension::onFormatSpecifierChanged() { - m_parent->dvDimension->FormatSpec.setValue(ui->leFormatSpecifier->text().toUtf8().constData()); + m_parent->getDimFeat()->FormatSpec.setValue(ui->leFormatSpecifier->text().toUtf8().constData()); recomputeFeature(); } void TaskDimension::onArbitraryChanged() { - m_parent->dvDimension->Arbitrary.setValue(ui->cbArbitrary->isChecked()); + m_parent->getDimFeat()->Arbitrary.setValue(ui->cbArbitrary->isChecked()); recomputeFeature(); } void TaskDimension::onFormatSpecifierOverToleranceChanged() { - m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData()); + m_parent->getDimFeat()->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData()); if (!ui->cbArbitraryTolerances->isChecked()) { ui->leFormatSpecifierUnderTolerance->setText(ui->leFormatSpecifierOverTolerance->text()); - m_parent->dvDimension->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData()); + m_parent->getDimFeat()->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData()); } recomputeFeature(); } void TaskDimension::onFormatSpecifierUnderToleranceChanged() { - m_parent->dvDimension->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData()); + m_parent->getDimFeat()->FormatSpecUnderTolerance.setValue(ui->leFormatSpecifierUnderTolerance->text().toUtf8().constData()); if (!ui->cbArbitraryTolerances->isChecked()) { ui->leFormatSpecifierOverTolerance->setText(ui->leFormatSpecifierUnderTolerance->text()); - m_parent->dvDimension->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData()); + m_parent->getDimFeat()->FormatSpecOverTolerance.setValue(ui->leFormatSpecifierOverTolerance->text().toUtf8().constData()); } recomputeFeature(); } void TaskDimension::onArbitraryTolerancesChanged() { - m_parent->dvDimension->ArbitraryTolerances.setValue(ui->cbArbitraryTolerances->isChecked()); + m_parent->getDimFeat()->ArbitraryTolerances.setValue(ui->cbArbitraryTolerances->isChecked()); recomputeFeature(); } @@ -317,26 +317,26 @@ void TaskDimension::onDrawingStyleChanged() void TaskDimension::onOverrideToggled() { - m_parent->dvDimension->AngleOverride.setValue(ui->rbOverride->isChecked()); + m_parent->getDimFeat()->AngleOverride.setValue(ui->rbOverride->isChecked()); recomputeFeature(); } void TaskDimension::onDimAngleChanged() { - m_parent->dvDimension->LineAngle.setValue(ui->dsbDimAngle->value()); + m_parent->getDimFeat()->LineAngle.setValue(ui->dsbDimAngle->value()); recomputeFeature(); } void TaskDimension::onExtAngleChanged() { - m_parent->dvDimension->ExtensionAngle.setValue(ui->dsbExtAngle->value()); + m_parent->getDimFeat()->ExtensionAngle.setValue(ui->dsbExtAngle->value()); recomputeFeature(); } void TaskDimension::onDimUseDefaultClicked() { - pointPair points = m_parent->dvDimension->getLinearPoints(); + pointPair points = m_parent->getDimFeat()->getLinearPoints(); //duplicate coordinate conversion logic from QGIViewDimension Base::Vector2d first2(points.first.x, -points.first.y); Base::Vector2d second2(points.second.x, -points.second.y); @@ -354,7 +354,7 @@ void TaskDimension::onDimUseSelectionClicked() void TaskDimension::onExtUseDefaultClicked() { - pointPair points = m_parent->dvDimension->getLinearPoints(); + pointPair points = m_parent->getDimFeat()->getLinearPoints(); //duplicate coordinate conversion logic from QGIViewDimension Base::Vector2d first2(points.first.x, -points.first.y); Base::Vector2d second2(points.second.x, -points.second.y); diff --git a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp index 9249478558..ff2047c8df 100644 --- a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp @@ -53,7 +53,7 @@ using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; -TaskGeomHatch::TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp,bool mode) : +TaskGeomHatch::TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch, TechDrawGui::ViewProviderGeomHatch* inVp, bool mode) : ui(new Ui_TaskGeomHatch), m_hatch(inHatch), m_Vp(inVp), @@ -67,11 +67,6 @@ TaskGeomHatch::TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewP initUi(); } -TaskGeomHatch::~TaskGeomHatch() -{ -} - - void TaskGeomHatch::initUi() { ui->fcFile->setFileName(QString::fromUtf8(m_file.data(), m_file.size())); @@ -79,7 +74,7 @@ void TaskGeomHatch::initUi() QStringList qsNames = listToQ(names); ui->cbName->addItems(qsNames); - int nameIndex = ui->cbName->findText(QString::fromUtf8(m_name.data(),m_name.size())); + int nameIndex = ui->cbName->findText(QString::fromUtf8(m_name.data(), m_name.size())); if (nameIndex > -1) { ui->cbName->setCurrentIndex(nameIndex); } else { @@ -142,7 +137,7 @@ bool TaskGeomHatch::accept() { // Base::Console().Message("TGH::accept()\n"); updateValues(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); m_hatch->recomputeFeature(); //create the hatch lines TechDraw::DrawView* dv = static_cast(m_source); dv->requestPaint(); @@ -153,8 +148,8 @@ bool TaskGeomHatch::reject() { if (getCreateMode()) { std::string HatchName = m_hatch->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",HatchName.c_str()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')", HatchName.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); m_source->touch(); m_source->getDocument()->recompute(); } else { @@ -200,19 +195,19 @@ void TaskGeomHatch::updateValues() m_Vp->WeightPattern.setValue(m_weight); } -QStringList TaskGeomHatch::listToQ(std::vector in) +QStringList TaskGeomHatch::listToQ(std::vector inList) { QStringList result; - for (auto& s: in) { + for (auto& s: inList) { QString qs = QString::fromUtf8(s.data(), s.size()); result.append(qs); } return result; } -void TaskGeomHatch::changeEvent(QEvent *e) +void TaskGeomHatch::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -222,7 +217,7 @@ TaskDlgGeomHatch::TaskDlgGeomHatch(TechDraw::DrawGeomHatch* inHatch, TechDrawGui TaskDialog(), viewProvider(nullptr) { - widget = new TaskGeomHatch(inHatch,inVp, mode); + widget = new TaskGeomHatch(inHatch, inVp, mode); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_TreeView"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); @@ -233,9 +228,9 @@ TaskDlgGeomHatch::~TaskDlgGeomHatch() { } -void TaskDlgGeomHatch::setCreateMode(bool b) +void TaskDlgGeomHatch::setCreateMode(bool mode) { - widget->setCreateMode(b); + widget->setCreateMode(mode); } void TaskDlgGeomHatch::update() diff --git a/src/Mod/TechDraw/Gui/TaskGeomHatch.h b/src/Mod/TechDraw/Gui/TaskGeomHatch.h index 6f8dd70058..10f1725cc9 100644 --- a/src/Mod/TechDraw/Gui/TaskGeomHatch.h +++ b/src/Mod/TechDraw/Gui/TaskGeomHatch.h @@ -50,32 +50,24 @@ class TaskGeomHatch : public QWidget Q_OBJECT public: - TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp, bool mode); - ~TaskGeomHatch() override; + TaskGeomHatch(TechDraw::DrawGeomHatch* inHatch, TechDrawGui::ViewProviderGeomHatch* inVp, bool mode); + ~TaskGeomHatch() = default; -public: virtual bool accept(); virtual bool reject(); - void setCreateMode(bool b) { m_createMode = b;} - bool getCreateMode() { return m_createMode; } + void setCreateMode(bool mode) { m_createMode = mode;} + bool getCreateMode() const { return m_createMode; } + +protected: + void changeEvent(QEvent *event) override; + void initUi(); + void updateValues(); + void getParameters(); + QStringList listToQ(std::vector inList); protected Q_SLOTS: void onFileChanged(); -protected: - void changeEvent(QEvent *e) override; - void initUi(); -// bool resetUi(); - void updateValues(); - void getParameters(); - QStringList listToQ(std::vector in); - -private Q_SLOTS: - void onNameChanged(); - void onScaleChanged(); - void onLineWeightChanged(); - void onColorChanged(); - private: std::unique_ptr ui; TechDraw::DrawGeomHatch* m_hatch; @@ -94,6 +86,12 @@ private: bool m_createMode; +private Q_SLOTS: + void onNameChanged(); + void onScaleChanged(); + void onLineWeightChanged(); + void onColorChanged(); + }; class TaskDlgGeomHatch : public Gui::TaskView::TaskDialog @@ -101,11 +99,10 @@ class TaskDlgGeomHatch : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgGeomHatch(TechDraw::DrawGeomHatch* inHatch,TechDrawGui::ViewProviderGeomHatch* inVp, bool mode); + TaskDlgGeomHatch(TechDraw::DrawGeomHatch* inHatch, TechDrawGui::ViewProviderGeomHatch* inVp, bool mode); ~TaskDlgGeomHatch() override; const ViewProviderGeomHatch * getViewProvider() const { return viewProvider; } -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -114,18 +111,14 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } - void setCreateMode(bool b); + void setCreateMode(bool mode); void update(); -protected: - const ViewProviderGeomHatch *viewProvider; - private: + const ViewProviderGeomHatch *viewProvider; TaskGeomHatch * widget; Gui::TaskView::TaskBox* taskbox; }; diff --git a/src/Mod/TechDraw/Gui/TaskHatch.cpp b/src/Mod/TechDraw/Gui/TaskHatch.cpp index c5fe6a6f88..9e7412360f 100644 --- a/src/Mod/TechDraw/Gui/TaskHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskHatch.cpp @@ -182,13 +182,13 @@ void TaskHatch::createHatch() Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Hatch")); - Command::doCommand(Command::Doc,"App.activeDocument().addObject('TechDraw::DrawHatch','%s')",FeatName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.Label = '%s'",FeatName.c_str(),featLabel.str().c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().addObject('TechDraw::DrawHatch', '%s')", FeatName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.Label = '%s'", FeatName.c_str(), featLabel.str().c_str()); m_hatch = static_cast(doc->getObject(FeatName.c_str())); m_hatch->Source.setValue(m_dvp, m_subs); - Command::doCommand(Command::Doc,"App.activeDocument().%s.HatchPattern = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.HatchPattern = '%s'", FeatName.c_str(), Base::Tools::toStdString(ui->fcFile->fileName()).c_str()); @@ -213,7 +213,7 @@ void TaskHatch::updateHatch() Command::openCommand(QT_TRANSLATE_NOOP("Command", "Update Hatch")); - Command::doCommand(Command::Doc,"App.activeDocument().%s.HatchPattern = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.HatchPattern = '%s'", FeatName.c_str(), Base::Tools::toStdString(ui->fcFile->fileName()).c_str()); diff --git a/src/Mod/TechDraw/Gui/TaskHatch.h b/src/Mod/TechDraw/Gui/TaskHatch.h index 776a5b2758..3215307f96 100644 --- a/src/Mod/TechDraw/Gui/TaskHatch.h +++ b/src/Mod/TechDraw/Gui/TaskHatch.h @@ -54,7 +54,6 @@ public: explicit TaskHatch(TechDrawGui::ViewProviderHatch* inVp); ~TaskHatch() override; -public: virtual bool accept(); virtual bool reject(); @@ -103,7 +102,6 @@ public: explicit TaskDlgHatch(TechDrawGui::ViewProviderHatch* inVp); ~TaskDlgHatch() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -119,8 +117,6 @@ public: void update(); -protected: - private: TaskHatch * widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index f10f4113c4..22491ebf62 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -198,10 +198,6 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat, } -TaskLeaderLine::~TaskLeaderLine() -{ -} - void TaskLeaderLine::saveState() { if (m_lineFeat) { @@ -227,9 +223,9 @@ void TaskLeaderLine::updateTask() // blockUpdate = false; } -void TaskLeaderLine::changeEvent(QEvent *e) +void TaskLeaderLine::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -270,11 +266,11 @@ void TaskLeaderLine::setUiPrimary() //switch widgets related to ViewProvider on/off //there is no ViewProvider until some time after feature is created. -void TaskLeaderLine::enableVPUi(bool b) +void TaskLeaderLine::enableVPUi(bool enable) { - ui->cpLineColor->setEnabled(b); - ui->dsbWeight->setEnabled(b); - ui->cboxStyle->setEnabled(b); + ui->cpLineColor->setEnabled(enable); + ui->dsbWeight->setEnabled(enable); + ui->cboxStyle->setEnabled(enable); } void TaskLeaderLine::setUiEdit() @@ -365,13 +361,13 @@ void TaskLeaderLine::createLeaderFeature(std::vector converted) std::string PageName = m_basePage->getNameInDocument(); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Leader")); - Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')", - m_leaderType.c_str(),m_leaderName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)", - PageName.c_str(),m_leaderName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().addObject('%s', '%s')", + m_leaderType.c_str(), m_leaderName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", + PageName.c_str(), m_leaderName.c_str()); if (m_baseFeat) { - Command::doCommand(Command::Doc,"App.activeDocument().%s.LeaderParent = App.activeDocument().%s", - m_leaderName.c_str(),m_baseFeat->getNameInDocument()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.LeaderParent = App.activeDocument().%s", + m_leaderName.c_str(), m_baseFeat->getNameInDocument()); } App::DocumentObject* obj = m_basePage->getDocument()->getObject(m_leaderName.c_str()); @@ -379,7 +375,7 @@ void TaskLeaderLine::createLeaderFeature(std::vector converted) throw Base::RuntimeError("TaskLeaderLine - new markup object not found"); if (obj->isDerivedFrom(TechDraw::DrawLeaderLine::getClassTypeId())) { m_lineFeat = static_cast(obj); - m_lineFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true); + m_lineFeat->setPosition(Rez::appX(m_attachPoint.x), Rez::appX(- m_attachPoint.y), true); if (!converted.empty()) { m_lineFeat->WayPoints.setValues(converted); if (m_lineFeat->AutoHorizontal.getValue()) { @@ -420,7 +416,7 @@ void TaskLeaderLine::updateLeaderFeature() { // Base::Console().Message("TTL::updateLeaderFeature()\n"); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit Leader")); - //waypoints & x,y are updated by QGILeaderLine (for edits only!) + //waypoints & x, y are updated by QGILeaderLine (for edits only!) commonFeatureUpdate(); App::Color ac; ac.setValue(ui->cpLineColor->color()); @@ -450,13 +446,13 @@ void TaskLeaderLine::removeFeature() // Base::Console().Message("TTL::removeFeature()\n"); if (!m_lineFeat) return; - + if (m_createMode) { try { std::string PageName = m_basePage->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)", - PageName.c_str(),m_lineFeat->getNameInDocument()); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')", + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.removeView(App.activeDocument().%s)", + PageName.c_str(), m_lineFeat->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')", m_lineFeat->getNameInDocument()); } catch (...) { @@ -474,9 +470,9 @@ void TaskLeaderLine::removeFeature() } //********** Tracker routines ******************************************************************* -void TaskLeaderLine::onTrackerClicked(bool b) +void TaskLeaderLine::onTrackerClicked(bool clicked) { - Q_UNUSED(b); + Q_UNUSED(clicked); // Base::Console().Message("TTL::onTrackerClicked() m_pbTrackerState: %d\n", // m_pbTrackerState); if (m_vpp->getMDIViewPage() == nullptr) { @@ -521,7 +517,7 @@ void TaskLeaderLine::onTrackerClicked(bool b) QString msg = tr("Pick a starting point for leader line"); getMainWindow()->statusBar()->show(); - Gui::getMainWindow()->showMessage(msg,3000); + Gui::getMainWindow()->showMessage(msg, 3000); ui->pbTracker->setText(tr("Save Points")); ui->pbTracker->setEnabled(true); ui->pbCancelEdit->setEnabled(true); @@ -547,7 +543,7 @@ void TaskLeaderLine::onTrackerClicked(bool b) qgLead->startPathEdit(); QString msg = tr("Click and drag markers to adjust leader line"); getMainWindow()->statusBar()->show(); - Gui::getMainWindow()->showMessage(msg,3000); + Gui::getMainWindow()->showMessage(msg, 3000); ui->pbTracker->setText(tr("Save changes")); ui->pbTracker->setEnabled(true); ui->pbCancelEdit->setEnabled(true); @@ -564,7 +560,7 @@ void TaskLeaderLine::onTrackerClicked(bool b) QString msg = tr("Pick a starting point for leader line"); getMainWindow()->statusBar()->show(); - Gui::getMainWindow()->showMessage(msg,3000); + Gui::getMainWindow()->showMessage(msg, 3000); ui->pbTracker->setText(tr("Save changes")); ui->pbTracker->setEnabled(true); ui->pbCancelEdit->setEnabled(true); @@ -597,14 +593,14 @@ void TaskLeaderLine::startTracker() setEditCursor(Qt::CrossCursor); QString msg = tr("Left click to set a point"); Gui::getMainWindow()->statusBar()->show(); - Gui::getMainWindow()->showMessage(msg,3000); + Gui::getMainWindow()->showMessage(msg, 3000); } void TaskLeaderLine::onTrackerFinished(std::vector pts, QGIView* qgParent) { //in this case, we already know who the parent is. We don't need QGTracker to tell us. (void) qgParent; -// Base::Console().Message("TTL::onTrackerFinished() - parent: %X\n",qgParent); +// Base::Console().Message("TTL::onTrackerFinished() - parent: %X\n", qgParent); if (pts.empty()) { Base::Console().Error("TaskLeaderLine - no points available\n"); return; @@ -647,9 +643,9 @@ void TaskLeaderLine::removeTracker() } } -void TaskLeaderLine::onCancelEditClicked(bool b) +void TaskLeaderLine::onCancelEditClicked(bool clicked) { - Q_UNUSED(b); + Q_UNUSED(clicked); // Base::Console().Message("TTL::onCancelEditClicked() m_pbTrackerState: %d\n", // m_pbTrackerState); abandonEditSession(); @@ -675,18 +671,18 @@ QGIView* TaskLeaderLine::findParentQGIV() ViewProviderDrawingView* vpdv = dynamic_cast(gvp); if (!vpdv) return nullptr; - + return vpdv->getQView();; } -void TaskLeaderLine::setEditCursor(QCursor c) +void TaskLeaderLine::setEditCursor(QCursor cursor) { if (!m_vpp->getQGSPage()) { return; } if (m_baseFeat) { QGIView* qgivBase = m_vpp->getQGSPage()->findQViewForDocObj(m_baseFeat); - qgivBase->setCursor(c); + qgivBase->setCursor(cursor); } } @@ -697,7 +693,7 @@ void TaskLeaderLine::trackerPointsFromQPoints(std::vector pts) m_trackerPoints.clear(); for (auto& p: pts) { QPointF mapped = p - pts.front(); - Base::Vector3d convert(mapped.x(),mapped.y(),0.0); + Base::Vector3d convert(mapped.x(), mapped.y(), 0.0); m_trackerPoints.push_back(convert); } } @@ -724,7 +720,7 @@ void TaskLeaderLine::abandonEditSession() } QString msg = tr("In progress edit abandoned. Start over."); getMainWindow()->statusBar()->show(); - Gui::getMainWindow()->showMessage(msg,4000); + Gui::getMainWindow()->showMessage(msg, 4000); m_pbTrackerState = TRACKEREDIT; ui->pbTracker->setText(tr("Edit points")); @@ -742,10 +738,10 @@ void TaskLeaderLine::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskLeaderLine::enableTaskButtons(bool b) +void TaskLeaderLine::enableTaskButtons(bool enable) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(enable); + m_btnCancel->setEnabled(enable); } int TaskLeaderLine::getPrefArrowStyle() @@ -789,7 +785,7 @@ bool TaskLeaderLine::accept() m_trackerMode = QGTracker::TrackerMode::None; removeTracker(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); if (m_vpp->getMDIViewPage() != nullptr) { m_vpp->getMDIViewPage()->setContextMenuPolicy(m_saveContextPolicy); @@ -822,8 +818,8 @@ bool TaskLeaderLine::reject() removeTracker(); //make sure any dangling objects are cleaned up - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); if (m_vpp->getMDIViewPage()) { m_vpp->getMDIViewPage()->setContextMenuPolicy(m_saveContextPolicy); @@ -837,7 +833,7 @@ TaskDlgLeaderLine::TaskDlgLeaderLine(TechDraw::DrawView* baseFeat, TechDraw::DrawPage* page) : TaskDialog() { - widget = new TaskLeaderLine(baseFeat,page); + widget = new TaskLeaderLine(baseFeat, page); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_LeaderLine"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.h b/src/Mod/TechDraw/Gui/TaskLeaderLine.h index 939866356b..8cb09b9e44 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.h +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.h @@ -31,14 +31,6 @@ #include "QGTracker.h" -//TODO: make this a proper enum -#define TRACKERPICK 0 -#define TRACKEREDIT 1 -#define TRACKERCANCEL 2 -#define TRACKERCANCELEDIT 3 -#define TRACKERFINISHED 4 -#define TRACKERSAVE 5 - namespace TechDraw { class DrawPage; @@ -66,31 +58,26 @@ public: TaskLeaderLine(TechDraw::DrawView* baseFeat, TechDraw::DrawPage* page); explicit TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP); - ~TaskLeaderLine() override; + ~TaskLeaderLine() = default; -public Q_SLOTS: - void onTrackerClicked(bool b); - void onCancelEditClicked(bool b); - void onTrackerFinished(std::vector pts, TechDrawGui::QGIView* qgParent); - -public: virtual bool accept(); virtual bool reject(); - virtual void setCreateMode(bool b) { m_createMode = b; } + virtual void setCreateMode(bool mode) { m_createMode = mode; } virtual bool getCreateMode() { return m_createMode; } void updateTask(); void saveButtons(QPushButton* btnOK, QPushButton* btnCancel); - void enableTaskButtons(bool b); + void enableTaskButtons(bool enable); void recomputeFeature(); - -protected Q_SLOTS: - void onPointEditComplete(); +public Q_SLOTS: + void onTrackerClicked(bool clicked); + void onCancelEditClicked(bool clicked); + void onTrackerFinished(std::vector pts, TechDrawGui::QGIView* qgParent); protected: void trackerPointsFromQPoints(std::vector pts); - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void startTracker(); void removeTracker(); void abandonEditSession(); @@ -100,12 +87,10 @@ protected: void commonFeatureUpdate(); void removeFeature(); - void blockButtons(bool b); void setUiPrimary(); void setUiEdit(); - void enableTextUi(bool b); - void enableVPUi(bool b); - void setEditCursor(QCursor c); + void enableVPUi(bool enable); + void setEditCursor(QCursor cursor); QGIView* findParentQGIV(); int getPrefArrowStyle(); @@ -115,19 +100,15 @@ protected: void saveState(); void restoreState(); -private Q_SLOTS: - void onStartSymbolChanged(); - void onEndSymbolChanged(); - void onColorChanged(); - void onLineWidthChanged(); - void onLineStyleChanged(); +protected Q_SLOTS: + void onPointEditComplete(); private: std::unique_ptr ui; bool blockUpdate; QGTracker* m_tracker; - + ViewProviderPage* m_vpp; ViewProviderLeader* m_lineVP; TechDraw::DrawView* m_baseFeat; @@ -140,7 +121,7 @@ private: std::vector m_trackerPoints; Base::Vector3d m_attachPoint; - + bool m_createMode; QGEPath* m_leadLine; @@ -151,14 +132,21 @@ private: QGILeaderLine* m_qgLine; QPushButton* m_btnOK; QPushButton* m_btnCancel; - + int m_pbTrackerState; - + std::vector m_savePoints; double m_saveX; double m_saveY; bool m_haveMdi; + +private Q_SLOTS: + void onStartSymbolChanged(); + void onEndSymbolChanged(); + void onColorChanged(); + void onLineWidthChanged(); + void onLineStyleChanged(); }; class TaskDlgLeaderLine : public Gui::TaskView::TaskDialog @@ -171,7 +159,6 @@ public: explicit TaskDlgLeaderLine(TechDrawGui::ViewProviderLeader* leadVP); ~TaskDlgLeaderLine() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -181,15 +168,12 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); void modifyStandardButtons(QDialogButtonBox* box) override; -protected: - private: TaskLeaderLine * widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp index cdad561925..450f2ea874 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp @@ -218,7 +218,7 @@ void TaskLineDecor::applyDecorations() m_visible); TechDraw::GeomFormat* newGF = new TechDraw::GeomFormat(num, fmt); -// int idx = +// int idx = m_partFeat->addGeomFormat(newGF); } } @@ -240,7 +240,7 @@ bool TaskLineDecor::accept() m_partFeat->requestPaint(); //Gui::Command::updateActive(); //no chain of updates here - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -252,7 +252,7 @@ bool TaskLineDecor::reject() if (!doc) return false; - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } @@ -349,7 +349,7 @@ int TaskRestoreLines::countInvisibleCosmetics() int iCosmos = 0; const std::vector cosmos = m_partFeat->CosmeticEdges.getValues(); for (auto& c : cosmos) { - if (!c->m_format.m_visible) { + if (!c->m_format.m_visible) { iCosmos++; } } @@ -361,7 +361,7 @@ int TaskRestoreLines::countInvisibleCenters() int iCenter = 0; const std::vector centers = m_partFeat->CenterLines.getValues(); for (auto& c : centers) { - if (!c->m_format.m_visible) { + if (!c->m_format.m_visible) { iCenter++; } } @@ -391,7 +391,7 @@ void TaskRestoreLines::restoreInvisibleCosmetics() { const std::vector cosmos = m_partFeat->CosmeticEdges.getValues(); for (auto& c : cosmos) { - if (!c->m_format.m_visible) { + if (!c->m_format.m_visible) { c->m_format.m_visible = true; } } @@ -403,7 +403,7 @@ void TaskRestoreLines::restoreInvisibleCenters() { const std::vector centers = m_partFeat->CenterLines.getValues(); for (auto& c : centers) { - if (!c->m_format.m_visible) { + if (!c->m_format.m_visible) { c->m_format.m_visible = true; } } diff --git a/src/Mod/TechDraw/Gui/TaskLinkDim.cpp b/src/Mod/TechDraw/Gui/TaskLinkDim.cpp index 7cc34ac1ca..1ba57348e7 100644 --- a/src/Mod/TechDraw/Gui/TaskLinkDim.cpp +++ b/src/Mod/TechDraw/Gui/TaskLinkDim.cpp @@ -109,17 +109,17 @@ void TaskLinkDim::loadAvailDims() found++; if (dim->has3DReferences()) { if (dimReferencesSelection(dim)) { - loadToTree(dim,true,guiDoc); + loadToTree(dim, true, guiDoc); } else { continue; //already linked to something else } } else { - loadToTree(dim,false,guiDoc); + loadToTree(dim, false, guiDoc); } } } } - //if (found == 0) { "No matching Dimensions found in %s",m_page->getNameInDocument()) + //if (found == 0) { "No matching Dimensions found in %s", m_page->getNameInDocument()) } void TaskLinkDim::loadToTree(const TechDraw::DrawViewDimension* dim, const bool selected, Gui::Document* guiDoc) @@ -193,11 +193,11 @@ void TaskLinkDim::updateDims() // for (unsigned int iPart = 0; iPart < m_subs.size(); iPart++) { // parts.push_back(m_part); // } - dim->References3D.setValues(m_parts,m_subs); + dim->References3D.setValues(m_parts, m_subs); std::string DimName = dim->getNameInDocument(); std::string measureType = "True"; - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.MeasureType = \'%s\'", - DimName.c_str(),measureType.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.MeasureType = \'%s\'", + DimName.c_str(), measureType.c_str()); //dim->MeasureType.setValue("True"); } count = ui->selector->availableTreeWidget()->topLevelItemCount(); @@ -209,9 +209,9 @@ void TaskLinkDim::updateDims() if (dim && dimReferencesSelection(dim)) { std::string measureType = "Projected"; std::string DimName = dim->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.MeasureType = \'%s\'", - DimName.c_str(),measureType.c_str()); - dim->References3D.setValue(nullptr,""); //DVD.References3D + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.MeasureType = \'%s\'", + DimName.c_str(), measureType.c_str()); + dim->References3D.setValue(nullptr, ""); //DVD.References3D dim->clear3DMeasurements(); //DVD.measurement.References3D } } @@ -223,7 +223,7 @@ void TaskLinkDim::onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem Q_UNUSED(previous); // if (previous) { // Base::Console().Message("TRACE - TLD::onCurrent - text: %s data: %s is previous\n", -// qPrintable(previous->text(0)),qPrintable(previous->data(0, Qt::UserRole).toString())); +// qPrintable(previous->text(0)), qPrintable(previous->data(0, Qt::UserRole).toString())); // if (previous->treeWidget() == ui->selector->selectedTreeWidget()) { // Base::Console().Message("TRACE - TLD::onCurrent - previous belongs to selected\n"); // } @@ -233,7 +233,7 @@ void TaskLinkDim::onCurrentItemChanged(QTreeWidgetItem* current, QTreeWidgetItem // } // if (current) { // Base::Console().Message("TRACE - TLD::onCurrent - text: %s data: %s is current\n", -// qPrintable(current->text(0)),qPrintable(current->data(0, Qt::UserRole).toString())); +// qPrintable(current->text(0)), qPrintable(current->data(0, Qt::UserRole).toString())); // if (current->treeWidget() == ui->selector->selectedTreeWidget()) { // Base::Console().Message("TRACE - TLD::onCurrent - current belongs to selected\n"); // } @@ -254,19 +254,19 @@ bool TaskLinkDim::reject() return true; } -void TaskLinkDim::changeEvent(QEvent *e) +void TaskLinkDim::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -TaskDlgLinkDim::TaskDlgLinkDim(std::vector parts,std::vector& subs, TechDraw::DrawPage* page) : +TaskDlgLinkDim::TaskDlgLinkDim(std::vector parts, std::vector& subs, TechDraw::DrawPage* page) : TaskDialog() { - widget = new TaskLinkDim(parts,subs,page); + widget = new TaskLinkDim(parts, subs, page); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("TechDraw_LinkDimension"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); diff --git a/src/Mod/TechDraw/Gui/TaskLinkDim.h b/src/Mod/TechDraw/Gui/TaskLinkDim.h index 11c5221326..dec6a69e1c 100644 --- a/src/Mod/TechDraw/Gui/TaskLinkDim.h +++ b/src/Mod/TechDraw/Gui/TaskLinkDim.h @@ -22,8 +22,8 @@ #ifndef GUI_TASKVIEW_TASKLINKDIM_H #define GUI_TASKVIEW_TASKLINKDIM_H - -#include + +#include #include #include @@ -36,6 +36,7 @@ class Document; namespace TechDraw { class DrawViewDimension; +class DrawPage; } namespace TechDrawGui @@ -47,23 +48,22 @@ class TaskLinkDim : public QWidget Q_OBJECT public: - TaskLinkDim(std::vector parts,std::vector& subs, TechDraw::DrawPage* page); + TaskLinkDim(std::vector parts, std::vector& subs, TechDraw::DrawPage* page); ~TaskLinkDim() override; -public: bool accept(); bool reject(); -protected Q_SLOTS: - void onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*); - protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void loadAvailDims(); void updateDims(); - void loadToTree(const TechDraw::DrawViewDimension* dim, const bool selected, Gui::Document* guiDoc); + void loadToTree(const TechDraw::DrawViewDimension* dim, bool selected, Gui::Document* guiDoc); bool dimReferencesSelection(const TechDraw::DrawViewDimension* dim) const; +protected Q_SLOTS: + void onCurrentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*); + private: std::unique_ptr ui; const std::vector m_parts; @@ -76,10 +76,9 @@ class TaskDlgLinkDim : public Gui::TaskView::TaskDialog Q_OBJECT public: - TaskDlgLinkDim(std::vector parts,std::vector& subs, TechDraw::DrawPage* page); + TaskDlgLinkDim(std::vector parts, std::vector& subs, TechDraw::DrawPage* page); ~TaskDlgLinkDim() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -88,15 +87,11 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); -protected: - private: TaskLinkDim * widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp index 8da0ecd39e..c970c8c434 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.cpp @@ -36,12 +36,8 @@ #include #include #include -#include -#include #include -#include - #include #include @@ -54,7 +50,6 @@ #include "MDIViewPage.h" #include "ViewProviderPage.h" #include "ViewProviderProjGroup.h" -#include "ViewProviderProjGroupItem.h" #include "TaskProjGroup.h" #include @@ -101,15 +96,15 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : // Rotation buttons // Note we don't do the custom one here, as it's handled by [a different function that's held up in customs] - connect(ui->butTopRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); - connect(ui->butCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); - connect(ui->butRightRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); - connect(ui->butDownRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); - connect(ui->butLeftRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); - connect(ui->butCCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked(void))); + connect(ui->butTopRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); + connect(ui->butCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); + connect(ui->butRightRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); + connect(ui->butDownRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); + connect(ui->butLeftRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); + connect(ui->butCCWRotate, SIGNAL(clicked()), this, SLOT(rotateButtonClicked())); // //Reset button -// connect(ui->butReset, SIGNAL(clicked()), this, SLOT(onResetClicked(void))); +// connect(ui->butReset, SIGNAL(clicked()), this, SLOT(onResetClicked())); // Slot for Scale Type connect(ui->cmbScaleType, SIGNAL(currentIndexChanged(int)), this, SLOT(scaleTypeChanged(int))); @@ -117,13 +112,12 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : connect(ui->sbScaleDen, SIGNAL(valueChanged(int)), this, SLOT(scaleManuallyChanged(int))); // Slot for Projection Type (layout) -// connect(ui->projection, SIGNAL(currentIndexChanged(int)), this, SLOT(projectionTypeChanged(int))); connect(ui->projection, SIGNAL(currentIndexChanged(QString)), this, SLOT(projectionTypeChanged(QString))); // Spacing connect(ui->cbAutoDistribute, SIGNAL(clicked(bool)), this, SLOT(AutoDistributeClicked(bool))); - connect(ui->sbXSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged(void))); - connect(ui->sbYSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged(void))); + connect(ui->sbXSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged())); + connect(ui->sbYSpacing, SIGNAL(valueChanged(double)), this, SLOT(spacingChanged())); ui->sbXSpacing->setUnit(Base::Unit::Length); ui->sbYSpacing->setUnit(Base::Unit::Length); @@ -137,10 +131,6 @@ TaskProjGroup::TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode) : saveGroupState(); } -TaskProjGroup::~TaskProjGroup() -{ -} - void TaskProjGroup::saveGroupState() { // Base::Console().Message("TPG::saveGroupState()\n"); @@ -223,7 +213,7 @@ void TaskProjGroup::rotateButtonClicked() else if (clicked == ui->butRightRotate) multiView->rotate("Right"); else if (clicked == ui->butLeftRotate) multiView->rotate("Left"); else if (clicked == ui->butCWRotate ) multiView->spin("CW"); - else if (clicked == ui->butCCWRotate) multiView->spin("CCW"); + else if (clicked == ui->butCCWRotate) multiView->spin("CCW"); setUiPrimary(); } @@ -281,17 +271,17 @@ void TaskProjGroup::scaleTypeChanged(int index) multiView->Scale.setValue(scale); //unblock recompute } else { - Base::Console().Log("Error - TaskProjGroup::scaleTypeChanged - unknown scale type: %d\n",index); + Base::Console().Log("Error - TaskProjGroup::scaleTypeChanged - unknown scale type: %d\n", index); return; } } -void TaskProjGroup::AutoDistributeClicked(bool b) +void TaskProjGroup::AutoDistributeClicked(bool clicked) { if (blockUpdate) { return; } - multiView->AutoDistribute.setValue(b); + multiView->AutoDistribute.setValue(clicked); multiView->recomputeFeature(); } @@ -404,9 +394,9 @@ void TaskProjGroup::setFractionalScale(double newScale) blockUpdate = false; } -void TaskProjGroup::scaleManuallyChanged(int i) +void TaskProjGroup::scaleManuallyChanged(int unused) { - Q_UNUSED(i); + Q_UNUSED(unused); if(blockUpdate) return; if (!multiView->ScaleType.isValue("Custom")) { //ignore if not custom! @@ -423,9 +413,9 @@ void TaskProjGroup::scaleManuallyChanged(int i) multiView->recomputeFeature(); } -void TaskProjGroup::changeEvent(QEvent *e) +void TaskProjGroup::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -495,12 +485,12 @@ void TaskProjGroup::setUiPrimary() ui->lePrimary->setText(formatVector(frontDir)); } -QString TaskProjGroup::formatVector(Base::Vector3d v) +QString TaskProjGroup::formatVector(Base::Vector3d vec) { QString data = QString::fromLatin1("[%1 %2 %3]") - .arg(QLocale().toString(v.x, 'f', 2), - QLocale().toString(v.y, 'f', 2), - QLocale().toString(v.z, 'f', 2)); + .arg(QLocale().toString(vec.x, 'f', 2), + QLocale().toString(vec.y, 'f', 2), + QLocale().toString(vec.z, 'f', 2)); return data; } @@ -533,7 +523,7 @@ bool TaskProjGroup::accept() multiView->recomputeChildren(); multiView->recomputeFeature(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -549,12 +539,12 @@ bool TaskProjGroup::reject() std::string multiViewName = multiView->getNameInDocument(); std::string PageName = multiView->findParentPage()->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.purgeProjections()", + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.purgeProjections()", multiViewName.c_str()); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)", - PageName.c_str(),multiViewName.c_str()); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')",multiViewName.c_str()); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.removeView(App.activeDocument().%s)", + PageName.c_str(), multiViewName.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')", multiViewName.c_str()); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); } else { //set the DPG and it's views back to entry state. if (Gui::Command::hasPendingCommand()) { @@ -567,7 +557,7 @@ bool TaskProjGroup::reject() Base::Console().Log("TaskProjGroup: Edit mode - NO command is active\n"); } } - Gui::Command::runCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::runCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } @@ -579,7 +569,7 @@ TaskDlgProjGroup::TaskDlgProjGroup(TechDraw::DrawProjGroup* featView, bool mode) , multiView(featView) { //viewProvider = dynamic_cast(featView); - widget = new TaskProjGroup(featView,mode); + widget = new TaskProjGroup(featView, mode); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_ProjectionGroup"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); @@ -595,9 +585,9 @@ void TaskDlgProjGroup::update() widget->updateTask(); } -void TaskDlgProjGroup::setCreateMode(bool b) +void TaskDlgProjGroup::setCreateMode(bool mode) { - widget->setCreateMode(b); + widget->setCreateMode(mode); } void TaskDlgProjGroup::modifyStandardButtons(QDialogButtonBox* box) @@ -619,7 +609,7 @@ void TaskDlgProjGroup::open() void TaskDlgProjGroup::clicked(int i) { // Q_UNUSED(i); -// Base::Console().Message("TDPG::clicked(%X)\n",i); +// Base::Console().Message("TDPG::clicked(%X)\n", i); if (i == QMessageBox::Apply) { widget->apply(); } diff --git a/src/Mod/TechDraw/Gui/TaskProjGroup.h b/src/Mod/TechDraw/Gui/TaskProjGroup.h index 1f8c0a439e..fced399e71 100644 --- a/src/Mod/TechDraw/Gui/TaskProjGroup.h +++ b/src/Mod/TechDraw/Gui/TaskProjGroup.h @@ -23,8 +23,6 @@ #ifndef GUI_TASKVIEW_TASKVIEWGROUP_H #define GUI_TASKVIEW_TASKVIEWGROUP_H - -#include #include @@ -51,9 +49,8 @@ class TaskProjGroup : public QWidget public: TaskProjGroup(TechDraw::DrawProjGroup* featView, bool mode); - ~TaskProjGroup() override; + ~TaskProjGroup() = default; -public: virtual bool accept(); virtual bool reject(); virtual bool apply(); @@ -63,29 +60,14 @@ public: QPushButton* btnApply); void updateTask(); - std::pair nearestFraction(const double val, const long int maxDenom = 999) const; + std::pair nearestFraction(double val, long int maxDenom = 999) const; // Sets the numerator and denominator widgets to match newScale void setFractionalScale(double newScale); - void setCreateMode(bool b) { m_createMode = b;} - bool getCreateMode() { return m_createMode; } - -protected Q_SLOTS: - void viewToggled(bool toggle); - - /// Requests appropriate rotation of our DrawProjGroup - void rotateButtonClicked(); - -// void onResetClicked(void); -/* void projectionTypeChanged(int index);*/ - void projectionTypeChanged(QString qText); - void scaleTypeChanged(int index); - void AutoDistributeClicked(bool b); - /// Updates item spacing - void spacingChanged(); - void scaleManuallyChanged(int i); + void setCreateMode(bool mode) { m_createMode = mode;} + bool getCreateMode() const { return m_createMode; } protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; /// Connects and updates state of view checkboxes to match the state of multiView /*! @@ -97,12 +79,25 @@ protected: void saveGroupState(); void restoreGroupState(); - QString formatVector(Base::Vector3d v); + QString formatVector(Base::Vector3d vec); +protected Q_SLOTS: + void viewToggled(bool toggle); + + /// Requests appropriate rotation of our DrawProjGroup + void rotateButtonClicked(); + + void projectionTypeChanged(QString qText); + void scaleTypeChanged(int index); + void AutoDistributeClicked(bool clicked); + /// Updates item spacing + void spacingChanged(); + void scaleManuallyChanged(int unused); + +private: TechDraw::DrawPage* m_page; MDIViewPage* m_mdi; -private: std::unique_ptr ui; TechDraw::DrawProjGroup* multiView; bool m_createMode; @@ -126,13 +121,12 @@ private: std::vector m_saveViewNames; }; -/// Simulation dialog for the TaskView class TaskDlgProjGroup : public Gui::TaskView::TaskDialog { Q_OBJECT public: - TaskDlgProjGroup(TechDraw::DrawProjGroup* featView,bool mode); + TaskDlgProjGroup(TechDraw::DrawProjGroup* featView, bool mode); ~TaskDlgProjGroup() override; const ViewProviderProjGroup * getViewProvider() const { return viewProvider; } @@ -142,7 +136,6 @@ public: { return QDialogButtonBox::Ok | QDialogButtonBox::Apply | QDialogButtonBox::Cancel; } void modifyStandardButtons(QDialogButtonBox* box) override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -152,10 +145,9 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } - void setCreateMode(bool b); + void setCreateMode(bool mode); void update(); diff --git a/src/Mod/TechDraw/Gui/TaskProjection.cpp b/src/Mod/TechDraw/Gui/TaskProjection.cpp index ffee7ee49a..487cde5744 100644 --- a/src/Mod/TechDraw/Gui/TaskProjection.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjection.cpp @@ -80,18 +80,18 @@ bool TaskProjection::accept() Gui::View3DInventorViewer* viewer = static_cast(mdis.front())->getViewer(); SbVec3f pnt, dir; viewer->getNearPlane(pnt, dir); - float x=0, y=1,z=1; - dir.getValue(x,y,z); + float x=0, y=1, z=1; + dir.getValue(x, y,z); std::vector shapes = Gui::Selection().getObjectsOfType(); Gui::Command::openCommand("Project shape"); - Gui::Command::addModule(Gui::Command::Doc,"TechDraw"); + Gui::Command::addModule(Gui::Command::Doc, "TechDraw"); for (std::vector::iterator it = shapes.begin(); it != shapes.end(); ++it) { const char* object = (*it)->getNameInDocument(); Gui::Command::doCommand(Gui::Command::Doc, - "FreeCAD.ActiveDocument.addObject('TechDraw::FeatureProjection','%s_proj')", object); + "FreeCAD.ActiveDocument.addObject('TechDraw::FeatureProjection', '%s_proj')", object); Gui::Command::doCommand(Gui::Command::Doc, - "FreeCAD.ActiveDocument.ActiveObject.Direction=FreeCAD.Vector(%f,%f,%f)", x,y,z); + "FreeCAD.ActiveDocument.ActiveObject.Direction=FreeCAD.Vector(%f, %f, %f)", x, y,z); Gui::Command::doCommand(Gui::Command::Doc, "FreeCAD.ActiveDocument.ActiveObject.Source=FreeCAD.ActiveDocument.%s", object); Gui::Command::doCommand(Gui::Command::Doc, diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp index d73a03f3cc..40683f24bf 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.cpp @@ -55,17 +55,13 @@ #include "PreferencesGui.h" #include "QGSPage.h" -#include "QGVPage.h" #include "QGIView.h" -#include "QGIPrimPath.h" -#include "MDIViewPage.h" #include "ViewProviderPage.h" #include "ViewProviderRichAnno.h" #include "QGMText.h" #include "QGIRichAnno.h" #include "Rez.h" #include "mrichtextedit.h" -#include "mtextedit.h" #include "TaskRichAnno.h" @@ -171,10 +167,6 @@ TaskRichAnno::TaskRichAnno(TechDraw::DrawView* baseFeat, this, SLOT(onEditorClicked(bool))); } -TaskRichAnno::~TaskRichAnno() -{ -} - void TaskRichAnno::updateTask() { // blockUpdate = true; @@ -182,9 +174,9 @@ void TaskRichAnno::updateTask() // blockUpdate = false; } -void TaskRichAnno::changeEvent(QEvent *e) +void TaskRichAnno::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -211,17 +203,17 @@ void TaskRichAnno::setUiPrimary() ui->teAnnoText->setPlaceholderText(tr("Input the annotation text directly or start the rich text editor")); } -void TaskRichAnno::enableTextUi(bool b) +void TaskRichAnno::enableTextUi(bool enable) { - ui->pbEditor->setEnabled(b); - ui->teAnnoText->setEnabled(b); + ui->pbEditor->setEnabled(enable); + ui->teAnnoText->setEnabled(enable); } //switch widgets related to ViewProvider on/off //there is no ViewProvider until some time after feature is created. -void TaskRichAnno::enableVPUi(bool b) +void TaskRichAnno::enableVPUi(bool enable) { - Q_UNUSED(b); + Q_UNUSED(enable); // ui->cpLineColor->setEnabled(b); // ui->dsbWeight->setEnabled(b); // ui->cboxStyle->setEnabled(b); @@ -253,23 +245,20 @@ void TaskRichAnno::setUiEdit() } } -void TaskRichAnno::onEditorClicked(bool b) +void TaskRichAnno::onEditorClicked(bool clicked) { -// Base::Console().Message("TL::onEditorClicked(%d)\n",b); - Q_UNUSED(b); +// Base::Console().Message("TL::onEditorClicked(%d)\n", b); + Q_UNUSED(clicked); m_textDialog = new QDialog(nullptr); QString leadText = ui->teAnnoText->toHtml(); QString plainText = ui->teAnnoText->toPlainText(); -// Base::Console().Message("TRA::onEditorClicked - leadText: %s** plainText: %s**\n", -// qPrintable(leadText), qPrintable(plainText)); if (plainText.isEmpty()) { m_rte = new MRichTextEdit(m_textDialog); } else { m_rte = new MRichTextEdit(m_textDialog, leadText); } - //m_rte->setTextWidth(m_annoVP->MaxWidth); QGridLayout* gl = new QGridLayout(m_textDialog); - gl->addWidget(m_rte,0,0,1,1); + gl->addWidget(m_rte, 0,0, 1,1); m_textDialog->setWindowTitle(QObject::tr("Rich text editor")); m_textDialog->setMinimumWidth (400); m_textDialog->setMinimumHeight(400); @@ -319,14 +308,14 @@ void TaskRichAnno::createAnnoFeature() std::string PageName = m_basePage->getNameInDocument(); Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create Anno")); - Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')", - annoType.c_str(),annoName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)", - PageName.c_str(),annoName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().addObject('%s', '%s')", + annoType.c_str(), annoName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", + PageName.c_str(), annoName.c_str()); if (m_baseFeat) { - Command::doCommand(Command::Doc,"App.activeDocument().%s.AnnoParent = App.activeDocument().%s", - annoName.c_str(),m_baseFeat->getNameInDocument()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.AnnoParent = App.activeDocument().%s", + annoName.c_str(), m_baseFeat->getNameInDocument()); } App::DocumentObject* obj = m_basePage->getDocument()->getObject(annoName.c_str()); if (!obj) { @@ -392,7 +381,7 @@ void TaskRichAnno::updateAnnoFeature() void TaskRichAnno::commonFeatureUpdate() { // Base::Console().Message("TRA::commonFeatureUpdate()\n"); - m_annoFeat->setPosition(Rez::appX(m_attachPoint.x),Rez::appX(- m_attachPoint.y), true); + m_annoFeat->setPosition(Rez::appX(m_attachPoint.x), Rez::appX(- m_attachPoint.y), true); m_annoFeat->AnnoText.setValue(ui->teAnnoText->toHtml().toUtf8()); m_annoFeat->MaxWidth.setValue(ui->dsbMaxWidth->value().getValue()); m_annoFeat->ShowFrame.setValue(ui->cbShowFrame->isChecked()); @@ -408,9 +397,9 @@ void TaskRichAnno::removeFeature() try { // this doesn't remove the QGMText item?? std::string PageName = m_basePage->getNameInDocument(); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().%s.removeView(App.activeDocument().%s)", - PageName.c_str(),m_annoFeat->getNameInDocument()); - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().removeObject('%s')", + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().%s.removeView(App.activeDocument().%s)", + PageName.c_str(), m_annoFeat->getNameInDocument()); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().removeObject('%s')", m_annoFeat->getNameInDocument()); } catch (...) { @@ -451,14 +440,14 @@ QPointF TaskRichAnno::calcTextStartPos(double scale) points = dll->WayPoints.getValues(); } else { // Base::Console().Message("TRA::calcTextPos - m_baseFeat is not Leader\n"); - return QPointF(0.0,0.0); + return QPointF(0.0, 0.0); } } else { // Base::Console().Message("TRA::calcStartPos - no m_baseFeat\n"); if (m_basePage) { double w = Rez::guiX(m_basePage->getPageWidth() / 2.0); double h = Rez::guiX(m_basePage->getPageHeight() / 2.0); - return QPointF(w,h); + return QPointF(w, h); } else { Base::Console().Message("TRA::calcStartPos - no m_basePage\n"); //shouldn't happen. caught elsewhere } @@ -487,10 +476,10 @@ void TaskRichAnno::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskRichAnno::enableTaskButtons(bool b) +void TaskRichAnno::enableTaskButtons(bool enable) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(enable); + m_btnCancel->setEnabled(enable); } //****************************************************************************** @@ -516,7 +505,7 @@ bool TaskRichAnno::accept() m_annoFeat->requestPaint(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -540,8 +529,8 @@ bool TaskRichAnno::reject() } //make sure any dangling objects are cleaned up - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } @@ -551,17 +540,17 @@ TaskDlgRichAnno::TaskDlgRichAnno(TechDraw::DrawView* baseFeat, TechDraw::DrawPage* page) : TaskDialog() { - widget = new TaskRichAnno(baseFeat,page); + widget = new TaskRichAnno(baseFeat, page); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_RichTextAnnotation"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); Content.push_back(taskbox); } -TaskDlgRichAnno::TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP) +TaskDlgRichAnno::TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP) : TaskDialog() { - widget = new TaskRichAnno(leadVP); + widget = new TaskRichAnno(annoVP); taskbox = new Gui::TaskView::TaskBox(Gui::BitmapFactory().pixmap("actions/TechDraw_RichTextAnnotation"), widget->windowTitle(), true, nullptr); taskbox->groupLayout()->addWidget(widget); diff --git a/src/Mod/TechDraw/Gui/TaskRichAnno.h b/src/Mod/TechDraw/Gui/TaskRichAnno.h index 06a42a2125..d4bc2efced 100644 --- a/src/Mod/TechDraw/Gui/TaskRichAnno.h +++ b/src/Mod/TechDraw/Gui/TaskRichAnno.h @@ -58,30 +58,23 @@ class TaskRichAnno : public QWidget public: TaskRichAnno(TechDraw::DrawView* baseFeat, TechDraw::DrawPage* page); - explicit TaskRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP); - ~TaskRichAnno() override; + explicit TaskRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP); + ~TaskRichAnno() = default; -public Q_SLOTS: - void onEditorClicked(bool b); -/* void onViewPicked(QPointF pos, QGIView* qgParent);*/ - -public: virtual bool accept(); virtual bool reject(); - virtual void setCreateMode(bool b) { m_createMode = b; } + virtual void setCreateMode(bool mode) { m_createMode = mode; } virtual bool getCreateMode() { return m_createMode; } void updateTask(); void saveButtons(QPushButton* btnOK, QPushButton* btnCancel); - void enableTaskButtons(bool b); + void enableTaskButtons(bool enable); - -protected Q_SLOTS: - void onSaveAndExit(QString); - void onEditorExit(); +public Q_SLOTS: + void onEditorClicked(bool clicked); protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void createAnnoFeature(); void updateAnnoFeature(); @@ -90,14 +83,17 @@ protected: QPointF calcTextStartPos(double scale); - void blockButtons(bool b); void setUiPrimary(); void setUiEdit(); - void enableTextUi(bool b); - void enableVPUi(bool b); + void enableTextUi(bool enable); + void enableVPUi(bool enable); double prefWeight() const; App::Color prefLineColor(); +protected Q_SLOTS: + void onSaveAndExit(QString); + void onEditorExit(); + private: std::unique_ptr ui; bool blockUpdate; @@ -111,7 +107,7 @@ private: std::string m_qgParentName; Base::Vector3d m_attachPoint; - + bool m_createMode; QGMText* m_text; @@ -121,7 +117,7 @@ private: QGIRichAnno* m_qgAnno; QPushButton* m_btnOK; QPushButton* m_btnCancel; - + QDialog* m_textDialog; MRichTextEdit* m_rte; QString m_title; @@ -134,7 +130,7 @@ class TaskDlgRichAnno : public Gui::TaskView::TaskDialog public: TaskDlgRichAnno(TechDraw::DrawView* baseFeat, TechDraw::DrawPage* page); - explicit TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* leadVP); + explicit TaskDlgRichAnno(TechDrawGui::ViewProviderRichAnno* annoVP); ~TaskDlgRichAnno() override; public: @@ -147,7 +143,6 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.cpp b/src/Mod/TechDraw/Gui/TaskSectionView.cpp index cd06546cbc..552f6dd0a9 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.cpp +++ b/src/Mod/TechDraw/Gui/TaskSectionView.cpp @@ -54,11 +54,6 @@ #include #include -#include "Rez.h" -#include "MDIViewPage.h" -#include "QGVPage.h" -#include "QGIView.h" - //#include "ViewProviderPage.h" //#include "ViewProviderViewPart.h" @@ -70,7 +65,7 @@ using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; -//ctor for create +//ctor for create TaskSectionView::TaskSectionView(TechDraw::DrawViewPart* base) : ui(new Ui_TaskSectionView), m_base(base), @@ -135,10 +130,6 @@ TaskSectionView::TaskSectionView(TechDraw::DrawViewSection* section) : setUiEdit(); } -TaskSectionView::~TaskSectionView() -{ -} - void TaskSectionView::setUiPrimary() { // Base::Console().Message("TSV::setUiPrimary()\n"); @@ -189,7 +180,7 @@ void TaskSectionView::setUiEdit() ui->leSymbol->setText(qTemp); ui->sbScale->setValue(m_section->getScale()); ui->cmbScaleType->setCurrentIndex(m_section->ScaleType.getValue()); - + Base::Vector3d origin = m_section->SectionOrigin.getValue(); ui->sbOrgX->setUnit(Base::Unit::Length); ui->sbOrgX->setValue(origin.x); @@ -326,27 +317,27 @@ void TaskSectionView::scaleTypeChanged(int index) ui->sbScale->setValue(m_section->Scale.getValue()); } } else { - Base::Console().Log("Error - TaskSectionView::scaleTypeChanged - unknown scale type: %d\n",index); + Base::Console().Log("Error - TaskSectionView::scaleTypeChanged - unknown scale type: %d\n", index); return; } } -void TaskSectionView::checkAll(bool b) +void TaskSectionView::checkAll(bool check) { - ui->pbUp->setChecked(b); - ui->pbDown->setChecked(b); - ui->pbRight->setChecked(b); - ui->pbLeft->setChecked(b); + ui->pbUp->setChecked(check); + ui->pbDown->setChecked(check); + ui->pbRight->setChecked(check); + ui->pbLeft->setChecked(check); } -void TaskSectionView::enableAll(bool b) +void TaskSectionView::enableAll(bool enable) { - ui->leSymbol->setEnabled(b); - ui->sbScale->setEnabled(b); - ui->sbOrgX->setEnabled(b); - ui->sbOrgY->setEnabled(b); - ui->sbOrgZ->setEnabled(b); - ui->cmbScaleType->setEnabled(b); + ui->leSymbol->setEnabled(enable); + ui->sbScale->setEnabled(enable); + ui->sbOrgX->setEnabled(enable); + ui->sbOrgY->setEnabled(enable); + ui->sbOrgZ->setEnabled(enable); + ui->cmbScaleType->setEnabled(enable); } //****************************************************************************** @@ -354,7 +345,7 @@ bool TaskSectionView::apply() { // Base::Console().Message("TSV::apply() - m_dirName: %s\n", m_dirName.c_str()); if (m_dirName.empty()) { - std::string msg = + std::string msg = Base::Tools::toStdString(tr("Nothing to apply. No section direction picked yet")); Base::Console().Error((msg + "\n").c_str()); return false; @@ -416,25 +407,25 @@ void TaskSectionView::createSectionView() m_sectionName = m_base->getDocument()->getUniqueObjectName("SectionView"); std::string sectionType = "TechDraw::DrawViewSection"; - Command::doCommand(Command::Doc,"App.ActiveDocument.addObject('%s','%s')", - sectionType.c_str(),m_sectionName.c_str()); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.addView(App.ActiveDocument.%s)", + Command::doCommand(Command::Doc, "App.ActiveDocument.addObject('%s', '%s')", + sectionType.c_str(), m_sectionName.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.addView(App.ActiveDocument.%s)", m_savePageName.c_str(), m_sectionName.c_str()); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.BaseView = App.ActiveDocument.%s", - m_sectionName.c_str(),baseName.c_str()); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Source = App.ActiveDocument.%s.Source", - m_sectionName.c_str(),baseName.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.BaseView = App.ActiveDocument.%s", + m_sectionName.c_str(), baseName.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Source = App.ActiveDocument.%s.Source", + m_sectionName.c_str(), baseName.c_str()); Command::doCommand(Command::Doc, - "App.ActiveDocument.%s.SectionOrigin = FreeCAD.Vector(%.3f,%.3f,%.3f)", - m_sectionName.c_str(), + "App.ActiveDocument.%s.SectionOrigin = FreeCAD.Vector(%.3f, %.3f, %.3f)", + m_sectionName.c_str(), ui->sbOrgX->value().getValue(), ui->sbOrgY->value().getValue(), ui->sbOrgZ->value().getValue()); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Scale = %0.6f", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value().getValue()); int scaleType = ui->cmbScaleType->currentIndex(); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ScaleType = %d", m_sectionName.c_str(), scaleType); App::DocumentObject* newObj = m_base->getDocument()->getObject(m_sectionName.c_str()); @@ -457,38 +448,38 @@ void TaskSectionView::updateSectionView() Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Edit SectionView")); if (m_section) { - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.SectionDirection = '%s'", - m_sectionName.c_str(),m_dirName.c_str()); + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionDirection = '%s'", + m_sectionName.c_str(), m_dirName.c_str()); Command::doCommand(Command::Doc, - "App.ActiveDocument.%s.SectionOrigin = FreeCAD.Vector(%.3f,%.3f,%.3f)", - m_sectionName.c_str(), + "App.ActiveDocument.%s.SectionOrigin = FreeCAD.Vector(%.3f, %.3f, %.3f)", + m_sectionName.c_str(), ui->sbOrgX->value().getValue(), ui->sbOrgY->value().getValue(), ui->sbOrgZ->value().getValue()); QString qTemp = ui->leSymbol->text(); std::string temp = Base::Tools::toStdString(qTemp); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.SectionSymbol = '%s'", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.SectionSymbol = '%s'", m_sectionName.c_str(), temp.c_str()); std::string lblText = "Section " + - temp + + temp + " - " + temp; - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Label = '%s'", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Label = '%s'", m_sectionName.c_str(), lblText.c_str()); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.Scale = %0.6f", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.Scale = %0.6f", m_sectionName.c_str(), ui->sbScale->value().getValue()); int scaleType = ui->cmbScaleType->currentIndex(); - Command::doCommand(Command::Doc,"App.ActiveDocument.%s.ScaleType = %d", + Command::doCommand(Command::Doc, "App.ActiveDocument.%s.ScaleType = %d", m_sectionName.c_str(), scaleType); m_section->setCSFromBase(m_dirName.c_str()); } Gui::Command::commitCommand(); } -void TaskSectionView::failNoObject(std::string objectName) +void TaskSectionView::failNoObject(std::string objectName) { QString qObjectName = Base::Tools::fromStdString(objectName); QString msg = tr("Can not continue. Object * %1 * not found.").arg(qObjectName); @@ -517,7 +508,7 @@ bool TaskSectionView::isSectionValid() App::DocumentObject* sectionObj = m_doc->getObject(m_sectionName.c_str()); if (!sectionObj) return false; - + return true; } @@ -531,7 +522,7 @@ bool TaskSectionView::accept() } apply(); Gui::Command::updateActive(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -539,15 +530,15 @@ bool TaskSectionView::reject() { // Base::Console().Message("TSV::reject()\n"); if (!m_section) { //no section created, nothing to undo - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } - if (!isSectionValid()) { //section !exist. nothing to undo + if (!isSectionValid()) { //section !exist. nothing to undo if (isBaseValid()) { m_base->requestPaint(); } - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } @@ -555,7 +546,7 @@ bool TaskSectionView::reject() std::string SectionName = m_section->getNameInDocument(); Gui::Command::doCommand(Gui::Command::Gui, "App.ActiveDocument.%s.removeView(App.ActiveDocument.%s)", - m_savePageName.c_str(),SectionName.c_str()); + m_savePageName.c_str(), SectionName.c_str()); Gui::Command::doCommand(Gui::Command::Gui, "App.ActiveDocument.removeObject('%s')", SectionName.c_str()); @@ -569,14 +560,14 @@ bool TaskSectionView::reject() m_base->requestPaint(); } Gui::Command::updateActive(); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } -void TaskSectionView::changeEvent(QEvent *e) +void TaskSectionView::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } diff --git a/src/Mod/TechDraw/Gui/TaskSectionView.h b/src/Mod/TechDraw/Gui/TaskSectionView.h index 623fb1bfb7..4a676a5446 100644 --- a/src/Mod/TechDraw/Gui/TaskSectionView.h +++ b/src/Mod/TechDraw/Gui/TaskSectionView.h @@ -46,27 +46,13 @@ class TaskSectionView : public QWidget public: explicit TaskSectionView(TechDraw::DrawViewPart* base); explicit TaskSectionView(TechDraw::DrawViewSection* section); - ~TaskSectionView() override; + ~TaskSectionView() = default; -public: virtual bool accept(); virtual bool reject(); -protected Q_SLOTS: - void onUpClicked(); - void onDownClicked(); - void onLeftClicked(); - void onRightClicked(); - void onIdentifierChanged(); - void onScaleChanged(); - void onXChanged(); - void onYChanged(); - void onZChanged(); - void scaleTypeChanged(int index); - - protected: - void changeEvent(QEvent *e) override; + void changeEvent(QEvent *event) override; void saveSectionState(); void restoreSectionState(); @@ -80,13 +66,25 @@ protected: void setUiPrimary(); void setUiEdit(); - void checkAll(bool b); - void enableAll(bool b); + void checkAll(bool check); + void enableAll(bool enable); - void failNoObject(std::string objName); + void failNoObject(std::string objectName); bool isBaseValid(); bool isSectionValid(); +protected Q_SLOTS: + void onUpClicked(); + void onDownClicked(); + void onLeftClicked(); + void onRightClicked(); + void onIdentifierChanged(); + void onScaleChanged(); + void onXChanged(); + void onYChanged(); + void onZChanged(); + void scaleTypeChanged(int index); + private: std::unique_ptr ui; TechDraw::DrawViewPart* m_base; @@ -95,7 +93,7 @@ private: Base::Vector3d m_normal; Base::Vector3d m_direction; Base::Vector3d m_origin; - + std::string m_saveSymbol; std::string m_saveDirName; Base::Vector3d m_saveNormal; @@ -128,7 +126,6 @@ public: explicit TaskDlgSectionView(TechDraw::DrawViewSection* section); ~TaskDlgSectionView() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -137,12 +134,9 @@ public: bool accept() override; /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; - /// is called by the framework if the user presses the help button - void helpRequested() override { return;} QDialogButtonBox::StandardButtons getStandardButtons() const override { return QDialogButtonBox::Ok | QDialogButtonBox::Cancel; } -/* virtual void modifyStandardButtons(QDialogButtonBox* box);*/ void update(); @@ -151,8 +145,6 @@ public: bool isAllowedAlterDocument() const override { return false; } -protected: - private: TaskSectionView * widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h index c8c7362402..9bbb56039c 100644 --- a/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h +++ b/src/Mod/TechDraw/Gui/TaskSelectLineAttributes.h @@ -96,15 +96,10 @@ public: explicit TaskSelectLineAttributes(lineAttributes * ptActiveAttributes); ~TaskSelectLineAttributes() override; -public Q_SLOTS: - -public: virtual bool accept(); virtual bool reject(); void updateTask(); -protected Q_SLOTS: - protected: void changeEvent(QEvent *e) override; @@ -133,7 +128,6 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); diff --git a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp index 78d8cdb0cc..1dd838ccd2 100644 --- a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp +++ b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp @@ -47,11 +47,11 @@ SvgString::SvgString(int width, int height) svgStream << "\n"; } -void SvgString::addLine(int x1, int y1, int x2, int y2) +void SvgString::addLine(int xStart, int yStart, int xEnd, int yEnd) { svgStream << "\n"; } @@ -82,12 +82,12 @@ TaskSurfaceFinishSymbols::TaskSurfaceFinishSymbols(TechDraw::DrawViewPart* view) selectedView(view), ui(new Ui_TaskSurfaceFinishSymbols) { - raValues = {"RA50","RA25","RA12,5","RA6,3", - "RA3,2","RA1,6","RA0,8","RA0,4", - "RA0,2","RA0,1","RA0,05","RA0,025"}; - laySymbols = {"","=","⟂","X","M","C","R"}; - roughGrades = {"","N1","N2","N3","N4","N5", - "N6","N7","N8","N9","N10","N11"}; + raValues = {"RA50", "RA25", "RA12, 5", "RA6, 3", + "RA3, 2", "RA1, 6", "RA0, 8", "RA0, 4", + "RA0, 2", "RA0, 1", "RA0, 05", "RA0, 025"}; + laySymbols = {"", "=", "⟂", "X", "M", "C", "R"}; + roughGrades = {"", "N1", "N2", "N3", "N4", "N5", + "N6", "N7", "N8", "N9", "N10", "N11"}; ui->setupUi(this); setUiEdit(); } @@ -95,8 +95,8 @@ TaskSurfaceFinishSymbols::TaskSurfaceFinishSymbols(TechDraw::DrawViewPart* view) QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type) // return QPixmap showing a base symbol { - QImage img (50,64,QImage::Format_ARGB32_Premultiplied); - img.fill(QColor(240,240,240)); + QImage img (50, 64, QImage::Format_ARGB32_Premultiplied); + img.fill(QColor(240, 240, 240)); QPainter painter; painter.begin(&img); painter.setPen(QPen(Qt::black, 2, Qt::SolidLine, @@ -104,14 +104,14 @@ QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type) painter.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::TextAntialiasing); - painter.drawLine(QLine(0,44,12,64)); - painter.drawLine(QLine(12,64,42,14)); + painter.drawLine(QLine(0, 44, 12, 64)); + painter.drawLine(QLine(12, 64, 42, 14)); if (type == removeProhibit || type == removeProhibitAll) - painter.drawEllipse(QPoint(12,46),9,9); + painter.drawEllipse(QPoint(12, 46), 9,9); if (type == removeRequired || type == removeRequiredAll) - painter.drawLine(QLine(0,44,24,44)); + painter.drawLine(QLine(0, 44, 24, 44)); if (type > removeRequired) - painter.drawEllipse(QPoint(42,14),6,6); + painter.drawEllipse(QPoint(42, 14), 6,6); painter.end(); return QPixmap::fromImage(img); } @@ -119,52 +119,47 @@ QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type) std::string TaskSurfaceFinishSymbols::completeSymbol() // return string showing the complete symbol { - SvgString symbol(150,64); - symbol.addLine(0,44,12,64); - symbol.addLine(12,64,42,14); + SvgString symbol(150, 64); + symbol.addLine(0, 44, 12, 64); + symbol.addLine(12, 64, 42, 14); int moveLeft(0), maxTextLength(0); if (activeIcon == removeProhibit || activeIcon == removeProhibitAll) - symbol.addCircle(12,46,9); + symbol.addCircle(12, 46, 9); if (activeIcon == removeRequired || activeIcon == removeRequiredAll) - symbol.addLine(0,44,24,44); + symbol.addLine(0, 44, 24, 44); if (activeIcon > removeRequired) { - symbol.addCircle(42,14,6); + symbol.addCircle(42, 14, 6); moveLeft = 5 ; } std::string methodText = leMethod->text().toStdString(); - symbol.addText(42+moveLeft,11,methodText); + symbol.addText(42+moveLeft, 11, methodText); int methodTextLength = methodText.length(); if (isISO) { std::string raText = cbRA->itemText(cbRA->currentIndex()).toStdString(); - symbol.addText(42+moveLeft,30,raText); + symbol.addText(42+moveLeft, 30, raText); int raTextLength = raText.length(); - maxTextLength = std::max(methodTextLength,raTextLength)*9.25+moveLeft; + maxTextLength = std::max(methodTextLength, raTextLength)*9.25+moveLeft; } else { std::string sampleText = leSamLength->text().toStdString(); - symbol.addText(42+moveLeft,30,sampleText); + symbol.addText(42+moveLeft, 30, sampleText); int sampleTextLength = sampleText.length(); - maxTextLength = std::max(methodTextLength,sampleTextLength)*9.25+moveLeft; + maxTextLength = std::max(methodTextLength, sampleTextLength)*9.25+moveLeft; std::string minRoughtText = cbMinRought->itemText(cbMinRought->currentIndex()).toStdString(); - symbol.addText(-10,35,minRoughtText); + symbol.addText(-10, 35, minRoughtText); std::string maxRoughtText = cbMaxRought->itemText(cbMaxRought->currentIndex()).toStdString(); - symbol.addText(-10,20,maxRoughtText); + symbol.addText(-10, 20, maxRoughtText); } - symbol.addLine(42,14,42+maxTextLength,14); - symbol.addText(20,60,cbLay->itemText(cbLay->currentIndex()).toStdString()); - symbol.addText(-25,60,leAddition->text().toStdString()); + symbol.addLine(42, 14, 42+maxTextLength, 14); + symbol.addText(20, 60, cbLay->itemText(cbLay->currentIndex()).toStdString()); + symbol.addText(-25, 60, leAddition->text().toStdString()); std::string symbolAsString = symbol.finish(); return symbolAsString; } -TaskSurfaceFinishSymbols::~TaskSurfaceFinishSymbols() -{ - -} - void TaskSurfaceFinishSymbols::updateTask() { // blockUpdate = true; @@ -173,9 +168,9 @@ void TaskSurfaceFinishSymbols::updateTask() } -void TaskSurfaceFinishSymbols::changeEvent(QEvent *e) +void TaskSurfaceFinishSymbols::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -199,69 +194,69 @@ void TaskSurfaceFinishSymbols::setUiEdit() ui->graphicsView->setScene(symbolScene); // QLineEdit showing method leMethod = new(QLineEdit); - leMethod->resize(90,20); + leMethod->resize(90, 20); leMethod->setToolTip(QObject::tr("Method")); QGraphicsProxyWidget* proxyMethod = symbolScene->addWidget(leMethod); - proxyMethod->setPos(2,-142); + proxyMethod->setPos(2, -142); // QLineEdit showing addition leAddition = new(QLineEdit); - leAddition->resize(25,20); + leAddition->resize(25, 20); leAddition->setToolTip(QObject::tr("Addition")); QGraphicsProxyWidget* proxyAddition = symbolScene->addWidget(leAddition); - proxyAddition->setPos(-80,-85); + proxyAddition->setPos(-80, -85); proxyAddition->setZValue(-2); // QComboBox showing RA values cbRA = new(QComboBox); - cbRA->resize(90,20); + cbRA->resize(90, 20); for (const std::string& nextValue : raValues) cbRA->addItem(QString::fromStdString(nextValue)); cbRA->setToolTip(QObject::tr("Average roughness")); proxyRA = symbolScene->addWidget(cbRA); - proxyRA->setPos(2,-113); + proxyRA->setPos(2, -113); // QLineEdit showing sampling length value leSamLength = new(QLineEdit); - leSamLength->resize(90,20); + leSamLength->resize(90, 20); leSamLength->setToolTip(QObject::tr("Roughness sampling length")); proxySamLength = symbolScene->addWidget(leSamLength); - proxySamLength->setPos(2,-113); + proxySamLength->setPos(2, -113); proxySamLength->hide(); // QComboBox showing lay symbol cbLay = new(QComboBox); - cbLay->resize(40,20); + cbLay->resize(40, 20); for (const std::string& nextLay : laySymbols) cbLay->addItem(QString::fromStdString(nextLay)); cbLay->setToolTip(QObject::tr("Lay symbol")); QGraphicsProxyWidget* proxyLay = symbolScene->addWidget(cbLay); - proxyLay->setPos(-23,-85); + proxyLay->setPos(-23, -85); // QComboBox showing minimal roughness grade cbMinRought = new(QComboBox); - cbMinRought->resize(55,20); + cbMinRought->resize(55, 20); for (const std::string& nextGrade : roughGrades) cbMinRought->addItem(QString::fromStdString(nextGrade)); cbMinRought->setToolTip(QObject::tr("Minimum roughness grade number")); proxyMinRough = symbolScene->addWidget(cbMinRought); - proxyMinRough->setPos(-80,-118); + proxyMinRough->setPos(-80, -118); proxyMinRough-> setZValue(1); proxyMinRough->hide(); // QComboBox showing maximal roughness grade cbMaxRought = new(QComboBox); - cbMaxRought->resize(55,20); + cbMaxRought->resize(55, 20); for (const std::string& nextGrade : roughGrades) cbMaxRought->addItem(QString::fromStdString(nextGrade)); cbMaxRought->setToolTip(QObject::tr("Maximum roughness grade number")); proxyMaxRough = symbolScene->addWidget(cbMaxRought); - proxyMaxRough->setPos(-80,-143); + proxyMaxRough->setPos(-80, -143); proxyMaxRough->setZValue(1); proxyMaxRough->hide(); // add horizontal line - symbolScene->addLine(QLine(-8,-116,90,-116), - QPen(Qt::black,2,Qt::SolidLine, + symbolScene->addLine(QLine(-8, -116, 90, -116), + QPen(Qt::black, 2,Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin)); // add pixmap of the surface finish symbol QIcon symbolIcon = ui->pbIcon01->icon(); QGraphicsPixmapItem* pixmapItem = new(QGraphicsPixmapItem); - pixmapItem->setPixmap(symbolIcon.pixmap(50,64)); - pixmapItem->setPos(-50,-130); + pixmapItem->setPixmap(symbolIcon.pixmap(50, 64)); + pixmapItem->setPos(-50, -130); pixmapItem->setZValue(-1); symbolScene->addItem(pixmapItem); @@ -290,11 +285,11 @@ void TaskSurfaceFinishSymbols::onIconChanged() if (ui->pbIcon04 == pressedButton) activeIcon = anyMethodAll; if (ui->pbIcon05 == pressedButton) activeIcon = removeProhibitAll; if (ui->pbIcon06 == pressedButton) activeIcon = removeRequiredAll; - + QIcon symbolIcon = pressedButton->icon(); QGraphicsPixmapItem* pixmapItem = new(QGraphicsPixmapItem); - pixmapItem->setPixmap(symbolIcon.pixmap(50,64)); - pixmapItem->setPos(-50,-130); + pixmapItem->setPixmap(symbolIcon.pixmap(50, 64)); + pixmapItem->setPos(-50, -130); pixmapItem->setZValue(-1); symbolScene->addItem(pixmapItem); } @@ -316,7 +311,7 @@ void TaskSurfaceFinishSymbols::onASME() proxySamLength->show(); proxyMinRough->show(); proxyMaxRough->show(); - proxyRA->hide(); + proxyRA->hide(); } bool TaskSurfaceFinishSymbols::accept() @@ -324,7 +319,7 @@ bool TaskSurfaceFinishSymbols::accept() { Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Surface Finish Symbols")); App::Document *doc = Application::Instance->activeDocument()->getDocument(); - App::DocumentObject *docObject = doc->addObject("TechDraw::DrawViewSymbol","SurfaceSymbol"); + App::DocumentObject *docObject = doc->addObject("TechDraw::DrawViewSymbol", "SurfaceSymbol"); TechDraw::DrawViewSymbol *surfaceSymbol = dynamic_cast(docObject); surfaceSymbol->Symbol.setValue(completeSymbol()); surfaceSymbol->Rotation.setValue(ui->leAngle->text().toDouble()); diff --git a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h index 586791360b..3985cddfe3 100644 --- a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h +++ b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h @@ -1,4 +1,4 @@ -/*************************************************************************** +/*************************************************************************** * Copyright (c) 2022 edi * * * * This file is part of the FreeCAD CAx development system. * @@ -29,6 +29,8 @@ #include class QComboBox; +class QLineEdit; +class QGraphicsScene; namespace App { class DocumentObject; @@ -50,10 +52,9 @@ class Face; namespace TechDrawGui { -class QGVPage; +class QGSPage; class QGIView; class QGIPrimPath; -class MDIViewPage; class ViewProviderViewPart; class Ui_TaskSurfaceFinishSymbols; @@ -65,7 +66,7 @@ class SvgString public: SvgString(int width, int height); - void addLine(int x1, int y1, int x2, int y2); + void addLine(int xStart, int yStart, int xEnd, int yEnd); void addCircle(int xCenter, int yCenter, int radius); void addText(int xText, int yText, std::string text); std::string finish(); @@ -78,25 +79,14 @@ class TaskSurfaceFinishSymbols : public QWidget public: explicit TaskSurfaceFinishSymbols(TechDraw::DrawViewPart* view); - ~TaskSurfaceFinishSymbols() override; + ~TaskSurfaceFinishSymbols() = default; -public Q_SLOTS: - -public: virtual bool accept(); virtual bool reject(); void updateTask(); - -private Q_SLOTS: - void onIconChanged(); - void onISO(); - void onASME(); - -protected Q_SLOTS: protected: - void changeEvent(QEvent *e) override; - + void changeEvent(QEvent *event) override; void setUiEdit(); private: @@ -105,7 +95,8 @@ private: QPixmap baseSymbol(symbolType type); std::string completeSymbol(); TechDraw::DrawViewPart* selectedView; - QGraphicsScene* symbolScene; + QGraphicsScene* symbolScene; //note this is not QGSPage, but another scene only used to + //display symbols in this task's ui std::vector raValues, laySymbols, roughGrades; QGraphicsProxyWidget *proxyRA, *proxySamLength, *proxyMinRough, *proxyMaxRough; QLineEdit *leMethod, *leSamLength, *leAddition; @@ -113,6 +104,12 @@ private: symbolType activeIcon; bool isISO; std::unique_ptr ui; + +private Q_SLOTS: + void onIconChanged(); + void onISO(); + void onASME(); + }; // class TaskSurfaceFinishSymbols class TaskDlgSurfaceFinishSymbols : public Gui::TaskView::TaskDialog @@ -123,7 +120,6 @@ public: explicit TaskDlgSurfaceFinishSymbols(TechDraw::DrawViewPart* view); ~TaskDlgSurfaceFinishSymbols() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -133,13 +129,10 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); -protected: - private: TaskSurfaceFinishSymbols* widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp index 142f3c9399..81cc652a90 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.cpp @@ -62,15 +62,7 @@ #include #include "PreferencesGui.h" -#include "QGVPage.h" -#include "QGIView.h" -#include "QGIPrimPath.h" -#include "QGILeaderLine.h" -#include "MDIViewPage.h" -#include "ViewProviderPage.h" -#include "ViewProviderViewPart.h" #include "SymbolChooser.h" -#include "Rez.h" #include "TaskWeldingSymbol.h" #include "ui_TaskWeldingSymbol.h" @@ -80,9 +72,9 @@ using namespace TechDraw; using namespace TechDrawGui; //ctor for creation -TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leader) : +TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leadFeat) : ui(new Ui_TaskWeldingSymbol), - m_leadFeat(leader), + m_leadFeat(leadFeat), m_weldFeat(nullptr), m_arrowFeat(nullptr), m_otherFeat(nullptr), @@ -91,7 +83,6 @@ TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leader) : m_createMode(true), m_otherDirty(false) { -//TODO: why does DWS need DLL as parent? //existence of leader is guaranteed by CmdTechDrawWeldSymbol (CommandAnnotate.cpp) ui->setupUi(this); @@ -106,8 +97,8 @@ TaskWeldingSymbol::TaskWeldingSymbol(TechDraw::DrawLeaderLine* leader) : this, SLOT(onOtherEraseCreateClicked())); connect(ui->pbFlipSides, SIGNAL(clicked(bool)), this, SLOT(onFlipSidesCreateClicked())); - connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(const QString&)), - this, SLOT(onDirectorySelected(const QString&))); + connect(ui->fcSymbolDir, SIGNAL(fileNameSelected(QString)), + this, SLOT(onDirectorySelected(QString))); } //ctor for edit @@ -185,9 +176,9 @@ void TaskWeldingSymbol::updateTask() // blockUpdate = false; } -void TaskWeldingSymbol::changeEvent(QEvent *e) +void TaskWeldingSymbol::changeEvent(QEvent *event) { - if (e->type() == QEvent::LanguageChange) { + if (event->type() == QEvent::LanguageChange) { ui->retranslateUi(this); } } @@ -412,7 +403,7 @@ void TaskWeldingSymbol::onSymbolSelected(QString symbolPath, // Base::Console().Message("TWS::onSymbolSelected(%s) - source: %s\n", // qPrintable(symbolPath), qPrintable(source)); QIcon targetIcon(symbolPath); - QSize iconSize(32,32); + QSize iconSize(32, 32); QString arrow = tr("arrow"); QString other = tr("other"); if (source == arrow) { @@ -495,31 +486,31 @@ TechDraw::DrawWeldSymbol* TaskWeldingSymbol::createWeldingSymbol() TechDraw::DrawPage* page = m_leadFeat->findParentPage(); std::string pageName = page->getNameInDocument(); - Command::doCommand(Command::Doc,"App.activeDocument().addObject('%s','%s')", - symbolType.c_str(),symbolName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.addView(App.activeDocument().%s)", + Command::doCommand(Command::Doc, "App.activeDocument().addObject('%s', '%s')", + symbolType.c_str(), symbolName.c_str()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.addView(App.activeDocument().%s)", pageName.c_str(), symbolName.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.Leader = App.activeDocument().%s", - symbolName.c_str(),m_leadFeat->getNameInDocument()); + Command::doCommand(Command::Doc, "App.activeDocument().%s.Leader = App.activeDocument().%s", + symbolName.c_str(), m_leadFeat->getNameInDocument()); bool allAround = ui->cbAllAround->isChecked(); std::string allAroundText = allAround ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.AllAround = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.AllAround = %s", symbolName.c_str(), allAroundText.c_str()); bool fieldWeld = ui->cbFieldWeld->isChecked(); std::string fieldWeldText = fieldWeld ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.FieldWeld = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.FieldWeld = %s", symbolName.c_str(), fieldWeldText.c_str()); bool altWeld = ui->cbAltWeld->isChecked(); std::string altWeldText = altWeld ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.AlternatingWeld = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.AlternatingWeld = %s", symbolName.c_str(), altWeldText.c_str()); std::string tailText = ui->leTailText->text().toStdString(); tailText = Base::Tools::escapeEncodeString(tailText); - Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.TailText = '%s'", symbolName.c_str(), tailText.c_str()); App::DocumentObject* newObj = m_leadFeat->getDocument()->getObject(symbolName.c_str()); @@ -537,22 +528,22 @@ void TaskWeldingSymbol::updateWeldingSymbol() bool allAround = ui->cbAllAround->isChecked(); std::string allAroundText = allAround ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.AllAround = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.AllAround = %s", symbolName.c_str(), allAroundText.c_str()); bool fieldWeld = ui->cbFieldWeld->isChecked(); std::string fieldWeldText = fieldWeld ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.FieldWeld = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.FieldWeld = %s", symbolName.c_str(), fieldWeldText.c_str()); bool altWeld = ui->cbAltWeld->isChecked(); std::string altWeldText = altWeld ? "True" : "False"; - Command::doCommand(Command::Doc,"App.activeDocument().%s.AlternatingWeld = %s", + Command::doCommand(Command::Doc, "App.activeDocument().%s.AlternatingWeld = %s", symbolName.c_str(), altWeldText.c_str()); std::string tailText = ui->leTailText->text().toStdString(); tailText = Base::Tools::escapeEncodeString(tailText); - Command::doCommand(Command::Doc,"App.activeDocument().%s.TailText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.TailText = '%s'", symbolName.c_str(), tailText.c_str()); } @@ -570,13 +561,13 @@ void TaskWeldingSymbol::updateTiles() std::string leftText = Base::Tools::escapeEncodeString(m_arrowOut.leftText); std::string rightText = Base::Tools::escapeEncodeString(m_arrowOut.rightText); std::string centerText = Base::Tools::escapeEncodeString(m_arrowOut.centerText); - Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d", + Command::doCommand(Command::Doc, "App.activeDocument().%s.TileColumn = %d", tileName.c_str(), m_arrowOut.col); - Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.LeftText = '%s'", tileName.c_str(), leftText.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.RightText = '%s'", tileName.c_str(), rightText.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.CenterText = '%s'", tileName.c_str(), centerText.c_str()); if (!m_arrowOut.symbolPath.empty()) { // m_arrowFeat->replaceSymbol(m_arrowOut.symbolPath); @@ -595,13 +586,13 @@ void TaskWeldingSymbol::updateTiles() std::string leftText = Base::Tools::escapeEncodeString(m_otherOut.leftText); std::string rightText = Base::Tools::escapeEncodeString(m_otherOut.rightText); std::string centerText = Base::Tools::escapeEncodeString(m_otherOut.centerText); - Command::doCommand(Command::Doc,"App.activeDocument().%s.TileColumn = %d", + Command::doCommand(Command::Doc, "App.activeDocument().%s.TileColumn = %d", tileName.c_str(), m_otherOut.col); - Command::doCommand(Command::Doc,"App.activeDocument().%s.LeftText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.LeftText = '%s'", tileName.c_str(), leftText.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.RightText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.RightText = '%s'", tileName.c_str(), rightText.c_str()); - Command::doCommand(Command::Doc,"App.activeDocument().%s.CenterText = '%s'", + Command::doCommand(Command::Doc, "App.activeDocument().%s.CenterText = '%s'", tileName.c_str(), centerText.c_str()); // m_otherFeat->replaceSymbol(m_otherOut.symbolPath); m_otherFeat->SymbolFile.setValue(m_otherOut.symbolPath); @@ -618,10 +609,10 @@ void TaskWeldingSymbol::saveButtons(QPushButton* btnOK, m_btnCancel = btnCancel; } -void TaskWeldingSymbol::enableTaskButtons(bool b) +void TaskWeldingSymbol::enableTaskButtons(bool enable) { - m_btnOK->setEnabled(b); - m_btnCancel->setEnabled(b); + m_btnOK->setEnabled(enable); + m_btnCancel->setEnabled(enable); } //****************************************************************************** @@ -652,7 +643,7 @@ bool TaskWeldingSymbol::accept() m_weldFeat->recomputeFeature(); // m_weldFeat->requestPaint(); //not a dv! } - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return true; } @@ -662,8 +653,8 @@ bool TaskWeldingSymbol::reject() // Base::Console().Message("TWS::reject()\n"); //nothing to remove. - Gui::Command::doCommand(Gui::Command::Gui,"App.activeDocument().recompute()"); - Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()"); + Gui::Command::doCommand(Gui::Command::Gui, "App.activeDocument().recompute()"); + Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.resetEdit()"); return false; } diff --git a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h index e541d05b9f..0f36f293d1 100644 --- a/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h +++ b/src/Mod/TechDraw/Gui/TaskWeldingSymbol.h @@ -95,10 +95,17 @@ class TechDrawGuiExport TaskWeldingSymbol : public QWidget Q_OBJECT public: - TaskWeldingSymbol(TechDraw::DrawLeaderLine* baseFeat); + TaskWeldingSymbol(TechDraw::DrawLeaderLine* leadFeat); TaskWeldingSymbol(TechDraw::DrawWeldSymbol* weldFeat); ~TaskWeldingSymbol(); + virtual bool accept(); + virtual bool reject(); + void updateTask(); + void saveButtons(QPushButton* btnOK, + QPushButton* btnCancel); + void enableTaskButtons(bool enable); + public Q_SLOTS: void symbolDialog(const char* source); void onArrowSymbolCreateClicked(); @@ -115,25 +122,14 @@ public Q_SLOTS: void onDirectorySelected(const QString& newDir); void onSymbolSelected(QString symbolPath, QString source); -public: - virtual bool accept(); - virtual bool reject(); - void updateTask(); - void saveButtons(QPushButton* btnOK, - QPushButton* btnCancel); - void enableTaskButtons(bool b); - -protected Q_SLOTS: - protected: - void changeEvent(QEvent *e); + void changeEvent(QEvent *event); void setUiPrimary(void); void setUiEdit(); TechDraw::DrawWeldSymbol* createWeldingSymbol(void); void updateWeldingSymbol(void); -/* std::vector createTiles(void);*/ void getTileFeats(void); void updateTiles(void); @@ -149,8 +145,6 @@ private: TechDraw::DrawLeaderLine* m_leadFeat; TechDraw::DrawWeldSymbol* m_weldFeat; -/* TechDraw::DrawTileWeld* m_arrowIn; //save starting values*/ -/* TechDraw::DrawTileWeld* m_otherIn;*/ TechDraw::DrawTileWeld* m_arrowFeat; TechDraw::DrawTileWeld* m_otherFeat; @@ -179,7 +173,6 @@ public: explicit TaskDlgWeldingSymbol(TechDraw::DrawWeldSymbol* weld); ~TaskDlgWeldingSymbol() override; -public: /// is called the TaskView when the dialog is opened void open() override; /// is called by the framework if an button is clicked which has no accept or reject role @@ -189,15 +182,12 @@ public: /// is called by the framework if the dialog is rejected (Cancel) bool reject() override; /// is called by the framework if the user presses the help button - void helpRequested() override { return;} bool isAllowedAlterDocument() const override { return false; } void update(); void modifyStandardButtons(QDialogButtonBox* box) override; -protected: - private: TaskWeldingSymbol* widget; Gui::TaskView::TaskBox* taskbox; diff --git a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp index a8a8f64e3d..1c33eedaf6 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderBalloon.cpp @@ -105,7 +105,7 @@ bool ViewProviderBalloon::setEdit(int ModNum) void ViewProviderBalloon::updateData(const App::Property* p) { - //Balloon handles X,Y updates differently that other QGIView + //Balloon handles X, Y updates differently that other QGIView //call QGIViewBalloon::updateView if (p == &(getViewObject()->X) || p == &(getViewObject()->Y) ){ @@ -115,7 +115,7 @@ void ViewProviderBalloon::updateData(const App::Property* p) } } - //Skip QGIView X,Y processing - do not call ViewProviderDrawingView + //Skip QGIView X, Y processing - do not call ViewProviderDrawingView Gui::ViewProviderDocumentObject::updateData(p); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp index 57b7e98977..60b1ce3784 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDimension.cpp @@ -66,13 +66,13 @@ ViewProviderDimension::ViewProviderDimension() ADD_PROPERTY_TYPE(Font, (Preferences::labelFont().c_str()), group, App::Prop_None, "The name of the font to use"); - ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), + ADD_PROPERTY_TYPE(Fontsize, (Preferences::dimFontSizeMM()), group, (App::PropertyType)(App::Prop_None), "Dimension text size in units"); - ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, (App::PropertyType)(App::Prop_None), + ADD_PROPERTY_TYPE(LineWidth, (prefWeight()), group, (App::PropertyType)(App::Prop_None), "Dimension line width"); ADD_PROPERTY_TYPE(Color, (prefColor()), group, App::Prop_None, "Color of the dimension"); - ADD_PROPERTY_TYPE(StandardAndStyle, (prefStandardAndStyle()), group, App::Prop_None, + ADD_PROPERTY_TYPE(StandardAndStyle, (prefStandardAndStyle()), group, App::Prop_None, "Standard and style according to which dimension is drawn"); StandardAndStyle.setEnums(StandardAndStyleEnums); @@ -153,7 +153,7 @@ void ViewProviderDimension::updateData(const App::Property* p) } } - //Dimension handles X,Y updates differently that other QGIView + //Dimension handles X, Y updates differently that other QGIView //call QGIViewDimension::updateView if (p == &(getViewObject()->X) || p == &(getViewObject()->Y) ){ @@ -163,7 +163,7 @@ void ViewProviderDimension::updateData(const App::Property* p) } } - //Skip QGIView X,Y processing - do not call ViewProviderDrawingView + //Skip QGIView X, Y processing - do not call ViewProviderDrawingView Gui::ViewProviderDocumentObject::updateData(p); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp index 8cdd6df927..eb2c0928a0 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.cpp @@ -56,11 +56,11 @@ ViewProviderDrawingView::ViewProviderDrawingView() sPixmap = "TechDraw_TreeView"; static const char *group = "Base"; - ADD_PROPERTY_TYPE(KeepLabel ,(false),group,App::Prop_None,"Keep Label on Page even if toggled off"); + ADD_PROPERTY_TYPE(KeepLabel ,(false), group, App::Prop_None, "Keep Label on Page even if toggled off"); // Do not show in property editor why? wf WF: because DisplayMode applies only to coin and we // don't use coin. - DisplayMode.setStatus(App::Property::Hidden,true); + DisplayMode.setStatus(App::Property::Hidden, true); } ViewProviderDrawingView::~ViewProviderDrawingView() @@ -194,7 +194,7 @@ void ViewProviderDrawingView::finishRestoring() void ViewProviderDrawingView::updateData(const App::Property* prop) { - //only move the view on X,Y change + //only move the view on X, Y change if (prop == &(getViewObject()->X) || prop == &(getViewObject()->Y) ){ QGIView* qgiv = getQView(); @@ -230,7 +230,7 @@ Gui::MDIView *ViewProviderDrawingView::getMDIView() const return getMDIViewPage(); } -void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv) +void ViewProviderDrawingView::onGuiRepaint(const TechDraw::DrawView* dv) { // Base::Console().Message("VPDV::onGuiRepaint(%s) - this: %x\n", dv->getNameInDocument(), this); Gui::Document* guiDoc = Gui::Application::Instance->getDocument(getViewObject()->getDocument()); diff --git a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h index 61301a0077..0f2206115c 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h +++ b/src/Mod/TechDraw/Gui/ViewProviderDrawingView.h @@ -26,7 +26,7 @@ #include -#include +#include #include #include @@ -77,7 +77,7 @@ public: virtual TechDraw::DrawView* getViewObject() const; void showProgressMessage(const std::string featureName, const std::string text) const; - + void onGuiRepaint(const TechDraw::DrawView* dv); void onProgressMessage(const TechDraw::DrawView* dv, const std::string featureName, diff --git a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp index a1da58b78e..8797ccf332 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderGeomHatch.cpp @@ -58,9 +58,9 @@ ViewProviderGeomHatch::ViewProviderGeomHatch() static const char *vgroup = "GeomHatch"; - ADD_PROPERTY_TYPE(ColorPattern,(TechDraw::DrawGeomHatch::prefGeomHatchColor()), - vgroup,App::Prop_None,"Color of the pattern"); - ADD_PROPERTY_TYPE(WeightPattern,(0),vgroup,App::Prop_None,"GeometricHatch pattern line thickness"); + ADD_PROPERTY_TYPE(ColorPattern, (TechDraw::DrawGeomHatch::prefGeomHatchColor()), + vgroup, App::Prop_None, "Color of the pattern"); + ADD_PROPERTY_TYPE(WeightPattern, (0), vgroup, App::Prop_None, "GeometricHatch pattern line thickness"); getParameters(); @@ -86,7 +86,7 @@ bool ViewProviderGeomHatch::setEdit(int ModNum) projDlg->setCreateMode(false); Gui::Control().showDialog(projDlg); } else { - Gui::Control().showDialog(new TaskDlgGeomHatch(getViewObject(),this,false)); + Gui::Control().showDialog(new TaskDlgGeomHatch(getViewObject(), this, false)); } return true; diff --git a/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp b/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp index 19c1bced86..5f1a972172 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderHatch.cpp @@ -45,8 +45,8 @@ using namespace TechDrawGui; //original range is far too broad for drawing. causes massive loop counts. //App::PropertyFloatConstraint::Constraints ViewProviderHatch::scaleRange = {Precision::Confusion(), // std::numeric_limits::max(), -// pow(10,- Base::UnitsApi::getDecimals())}; -App::PropertyFloatConstraint::Constraints ViewProviderHatch::scaleRange = {pow(10,- Base::UnitsApi::getDecimals()), +// pow(10, - Base::UnitsApi::getDecimals())}; +App::PropertyFloatConstraint::Constraints ViewProviderHatch::scaleRange = {pow(10, - Base::UnitsApi::getDecimals()), 1000.0, 0.1}; @@ -61,9 +61,9 @@ ViewProviderHatch::ViewProviderHatch() sPixmap = "TechDraw_TreeHatch"; static const char *vgroup = "Hatch"; - ADD_PROPERTY_TYPE(HatchColor,(TechDraw::DrawHatch::prefSvgHatchColor()), - vgroup,App::Prop_None,"The color of the hatch pattern"); - ADD_PROPERTY_TYPE(HatchScale,(1.0),vgroup,App::Prop_None,"Hatch pattern size adjustment"); + ADD_PROPERTY_TYPE(HatchColor, (TechDraw::DrawHatch::prefSvgHatchColor()), + vgroup, App::Prop_None, "The color of the hatch pattern"); + ADD_PROPERTY_TYPE(HatchScale, (1.0), vgroup, App::Prop_None, "Hatch pattern size adjustment"); HatchScale.setConstraints(&scaleRange); } @@ -79,7 +79,7 @@ bool ViewProviderHatch::setEdit(int ModNum) if (Gui::Control().activeDialog()) { return false; //TaskPanel already open! } - + // clear the selection (convenience) Gui::Selection().clearSelection(); Gui::Control().showDialog(new TaskDlgHatch(this)); diff --git a/src/Mod/TechDraw/Gui/ViewProviderImage.cpp b/src/Mod/TechDraw/Gui/ViewProviderImage.cpp index d109d6b4e2..0d3f123264 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderImage.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderImage.cpp @@ -38,7 +38,7 @@ ViewProviderImage::ViewProviderImage() { sPixmap = "actions/TechDraw_Image"; - ADD_PROPERTY_TYPE(Crop ,(false),"Image", App::Prop_None, "Crop image to Width x Height"); + ADD_PROPERTY_TYPE(Crop ,(false), "Image", App::Prop_None, "Crop image to Width x Height"); } ViewProviderImage::~ViewProviderImage() diff --git a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp index 2c9e8c4640..2c9161d7da 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderLeader.cpp @@ -67,10 +67,10 @@ ViewProviderLeader::ViewProviderLeader() static const char *group = "Line Format"; - ADD_PROPERTY_TYPE(LineWidth,(getDefLineWeight()),group,(App::PropertyType)(App::Prop_None),"Line width"); + ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group, (App::PropertyType)(App::Prop_None), "Line width"); LineStyle.setEnums(LineStyleEnums); - ADD_PROPERTY_TYPE(LineStyle,(1),group,(App::PropertyType)(App::Prop_None),"Line style"); - ADD_PROPERTY_TYPE(Color,(getDefLineColor()),group,App::Prop_None,"Color of the Markup"); + ADD_PROPERTY_TYPE(LineStyle, (1), group, (App::PropertyType)(App::Prop_None), "Line style"); + ADD_PROPERTY_TYPE(Color, (getDefLineColor()), group, App::Prop_None, "Color of the Markup"); } ViewProviderLeader::~ViewProviderLeader() @@ -79,7 +79,7 @@ ViewProviderLeader::~ViewProviderLeader() bool ViewProviderLeader::setEdit(int ModNum) { -// Base::Console().Message("VPL::setEdit(%d)\n",ModNum); +// Base::Console().Message("VPL::setEdit(%d)\n", ModNum); if (ModNum != ViewProvider::Default) { return ViewProviderDrawingView::setEdit(ModNum); } @@ -146,7 +146,7 @@ std::vector ViewProviderLeader::claimChildren() const } } return temp; - } + } catch (...) { std::vector tmp; return tmp; @@ -217,7 +217,7 @@ bool ViewProviderLeader::onDelete(const std::vector &) } QString bodyMessage; - QTextStream bodyMessageStream(&bodyMessage); + QTextStream bodyMessageStream(&bodyMessage); bodyMessageStream << qApp->translate("Std_Delete", "You cannot delete this leader line because\nit has a weld symbol that would become broken."); QMessageBox::warning(Gui::getMainWindow(), diff --git a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp index e576eeedec..8eca6933ae 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderPage.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderPage.cpp @@ -85,13 +85,13 @@ ViewProviderPage::ViewProviderPage() sPixmap = "TechDraw_TreePage"; static const char *group = "Grid"; - ADD_PROPERTY_TYPE(ShowFrames ,(true),group,App::Prop_None,"Show or hide View frames and Labels on this Page"); - ADD_PROPERTY_TYPE(ShowGrid ,(PreferencesGui::showGrid()),group,App::Prop_None,"Show or hide a grid on this Page"); + ADD_PROPERTY_TYPE(ShowFrames ,(true), group, App::Prop_None, "Show or hide View frames and Labels on this Page"); + ADD_PROPERTY_TYPE(ShowGrid ,(PreferencesGui::showGrid()), group, App::Prop_None, "Show or hide a grid on this Page"); ADD_PROPERTY_TYPE(GridSpacing, (PreferencesGui::gridSpacing()), group, (App::PropertyType)(App::Prop_None), "Grid line spacing in mm"); - ShowFrames.setStatus(App::Property::Hidden,true); - DisplayMode.setStatus(App::Property::Hidden,true); + ShowFrames.setStatus(App::Property::Hidden, true); + DisplayMode.setStatus(App::Property::Hidden, true); m_graphicsScene = new QGSPage(this); m_graphicsScene->setItemIndexMethod(QGraphicsScene::NoIndex); //this prevents crash when deleting dims. @@ -436,7 +436,7 @@ void ViewProviderPage::toggleFrameState() void ViewProviderPage::setTemplateMarkers(bool state) { -// Base::Console().Message("VPP::setTemplateMarkers(%d)\n",state); +// Base::Console().Message("VPP::setTemplateMarkers(%d)\n", state); App::DocumentObject *templateFeat = nullptr; templateFeat = getDrawPage()->Template.getValue(); Gui::Document* guiDoc = Gui::Application::Instance->getDocument(templateFeat->getDocument()); diff --git a/src/Mod/TechDraw/Gui/ViewProviderPage.h b/src/Mod/TechDraw/Gui/ViewProviderPage.h index ed8647b32c..3ec2ac0829 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderPage.h +++ b/src/Mod/TechDraw/Gui/ViewProviderPage.h @@ -81,7 +81,7 @@ public: TechDraw::DrawPage* getDrawPage() const; //slots & connections - void onGuiRepaint(const TechDraw::DrawPage* dp); + void onGuiRepaint(const TechDraw::DrawPage* dp); using Connection = boost::signals2::scoped_connection; Connection connectGuiRepaint; diff --git a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp index 31b23ab2d9..5890173caa 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderProjGroup.cpp @@ -93,7 +93,7 @@ bool ViewProviderProjGroup::setEdit(int ModNum) projDlg->setCreateMode(false); Gui::Control().showDialog(projDlg); } else { - Gui::Control().showDialog(new TaskDlgProjGroup(getObject(),false)); + Gui::Control().showDialog(new TaskDlgProjGroup(getObject(), false)); } return true; diff --git a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp index 4a3ccc77c8..6ec4f0851a 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderRichAnno.cpp @@ -59,7 +59,7 @@ ViewProviderRichAnno::ViewProviderRichAnno() static const char *group = "Frame Format"; - ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group,(App::PropertyType)(App::Prop_None), "Frame line width"); + ADD_PROPERTY_TYPE(LineWidth, (getDefLineWeight()), group, (App::PropertyType)(App::Prop_None), "Frame line width"); LineStyle.setEnums(LineStyleEnums); ADD_PROPERTY_TYPE(LineStyle, (1), group, (App::PropertyType)(App::Prop_None), "Frame line style"); ADD_PROPERTY_TYPE(LineColor, (getDefLineColor()), group, App::Prop_None, "The color of the frame"); diff --git a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp index c13f235085..59e437fb7d 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderTemplate.cpp @@ -60,7 +60,7 @@ ViewProviderTemplate::ViewProviderTemplate() { sPixmap = "TechDraw_TreePageTemplate"; - DisplayMode.setStatus(App::Property::Hidden,true); + DisplayMode.setStatus(App::Property::Hidden, true); } ViewProviderTemplate::~ViewProviderTemplate() @@ -98,7 +98,7 @@ void ViewProviderTemplate::onChanged(const App::Property *prop) hide(); } } - + Gui::ViewProviderDocumentObject::onChanged(prop); } @@ -118,7 +118,7 @@ void ViewProviderTemplate::hide() if (qTemplate) { qTemplate->hide(); } - + ViewProviderDocumentObject::hide(); } @@ -143,7 +143,7 @@ QGITemplate* ViewProviderTemplate::getQTemplate() void ViewProviderTemplate::setMarkers(bool state) { -// Base::Console().Message("VPT::setMarkers(%d)\n",state); +// Base::Console().Message("VPT::setMarkers(%d)\n", state); QGITemplate* qTemplate = getQTemplate(); QGISVGTemplate* qSvgTemplate = dynamic_cast (qTemplate); if (qSvgTemplate) { diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp index 30369092d5..e2fecf782a 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewClip.cpp @@ -43,7 +43,7 @@ ViewProviderViewClip::ViewProviderViewClip() // Do not show in property editor //DisplayMode.StatusBits.set(3, true); - DisplayMode.setStatus(App::Property::ReadOnly,true); + DisplayMode.setStatus(App::Property::ReadOnly, true); } ViewProviderViewClip::~ViewProviderViewClip() diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp index 085aa4eda2..58ca829df5 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewPart.cpp @@ -80,46 +80,46 @@ ViewProviderViewPart::ViewProviderViewPart() //default line weights double weight = TechDraw::LineGroup::getDefaultWidth("Thick"); - ADD_PROPERTY_TYPE(LineWidth,(weight),group,App::Prop_None,"The thickness of visible lines (line groups xx.2"); + ADD_PROPERTY_TYPE(LineWidth, (weight), group, App::Prop_None, "The thickness of visible lines (line groups xx.2"); weight = TechDraw::LineGroup::getDefaultWidth("Thin"); - ADD_PROPERTY_TYPE(HiddenWidth,(weight),group,App::Prop_None,"The thickness of hidden lines, if enabled (line groups xx.1)"); + ADD_PROPERTY_TYPE(HiddenWidth, (weight), group, App::Prop_None, "The thickness of hidden lines, if enabled (line groups xx.1)"); weight = TechDraw::LineGroup::getDefaultWidth("Graphic"); - ADD_PROPERTY_TYPE(IsoWidth,(weight),group,App::Prop_None,"The thickness of isoparameter lines, if enabled"); + ADD_PROPERTY_TYPE(IsoWidth, (weight), group, App::Prop_None, "The thickness of isoparameter lines, if enabled"); weight = TechDraw::LineGroup::getDefaultWidth("Extra"); - ADD_PROPERTY_TYPE(ExtraWidth,(weight),group,App::Prop_None,"The thickness of LineGroup Extra lines, if enabled"); + ADD_PROPERTY_TYPE(ExtraWidth, (weight), group, App::Prop_None, "The thickness of LineGroup Extra lines, if enabled"); Base::Reference hGrp = App::GetApplication().GetUserParameter().GetGroup("BaseApp")-> GetGroup("Preferences")->GetGroup("Mod/TechDraw/Decorations"); - double defScale = hGrp->GetFloat("CenterMarkScale",0.50); + double defScale = hGrp->GetFloat("CenterMarkScale", 0.50); bool defShowCenters = hGrp->GetBool("ShowCenterMarks", false); - + //decorations - ADD_PROPERTY_TYPE(HorizCenterLine ,(false),dgroup,App::Prop_None,"Show a horizontal centerline through view"); - ADD_PROPERTY_TYPE(VertCenterLine ,(false),dgroup,App::Prop_None,"Show a vertical centerline through view"); - ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters),dgroup,App::Prop_None,"Center marks on/off"); - ADD_PROPERTY_TYPE(CenterScale,(defScale),dgroup,App::Prop_None,"Center mark size adjustment, if enabled"); + ADD_PROPERTY_TYPE(HorizCenterLine ,(false), dgroup, App::Prop_None, "Show a horizontal centerline through view"); + ADD_PROPERTY_TYPE(VertCenterLine ,(false), dgroup, App::Prop_None, "Show a vertical centerline through view"); + ADD_PROPERTY_TYPE(ArcCenterMarks ,(defShowCenters), dgroup, App::Prop_None, "Center marks on/off"); + ADD_PROPERTY_TYPE(CenterScale, (defScale), dgroup, App::Prop_None, "Center mark size adjustment, if enabled"); //properties that affect Section Line - ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,dgroup,App::Prop_None,"Show/hide section line if applicable"); + ADD_PROPERTY_TYPE(ShowSectionLine ,(true) ,dgroup, App::Prop_None, "Show/hide section line if applicable"); SectionLineStyle.setEnums(LineStyleEnums); - ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), dgroup, App::Prop_None, + ADD_PROPERTY_TYPE(SectionLineStyle, (PreferencesGui::sectionLineStyle()), dgroup, App::Prop_None, "Set section line style if applicable"); - ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), dgroup, App::Prop_None, + ADD_PROPERTY_TYPE(SectionLineColor, (prefSectionColor()), dgroup, App::Prop_None, "Set section line color if applicable"); - + //properties that affect Detail Highlights HighlightLineStyle.setEnums(LineStyleEnums); - ADD_PROPERTY_TYPE(HighlightLineStyle, (prefHighlightStyle()), hgroup, App::Prop_None, + ADD_PROPERTY_TYPE(HighlightLineStyle, (prefHighlightStyle()), hgroup, App::Prop_None, "Set highlight line style if applicable"); - ADD_PROPERTY_TYPE(HighlightLineColor, (prefHighlightColor()), hgroup, App::Prop_None, + ADD_PROPERTY_TYPE(HighlightLineColor, (prefHighlightColor()), hgroup, App::Prop_None, "Set highlight line color if applicable"); - ADD_PROPERTY_TYPE(HighlightAdjust,(0.0),hgroup,App::Prop_None,"Adjusts the rotation of the Detail highlight"); + ADD_PROPERTY_TYPE(HighlightAdjust, (0.0), hgroup, App::Prop_None, "Adjusts the rotation of the Detail highlight"); - ADD_PROPERTY_TYPE(ShowAllEdges ,(false) ,dgroup,App::Prop_None,"Temporarily show invisible lines"); + ADD_PROPERTY_TYPE(ShowAllEdges ,(false) ,dgroup, App::Prop_None, "Temporarily show invisible lines"); } ViewProviderViewPart::~ViewProviderViewPart() @@ -222,7 +222,7 @@ bool ViewProviderViewPart::setEdit(int ModNum) } TechDraw::DrawViewPart* dvp = getViewObject(); TechDraw::DrawViewDetail* dvd = dynamic_cast(dvp); - if (dvd) { + if (dvd) { // clear the selection (convenience) Gui::Selection().clearSelection(); Gui::Control().showDialog(new TaskDlgDetail(dvd)); @@ -235,12 +235,12 @@ bool ViewProviderViewPart::setEdit(int ModNum) dvd->getNameInDocument()); //Gui.ActiveDocument.resetEdit() -//>>> # Gui.Selection.addSelection('aaStart121','Detail') +//>>> # Gui.Selection.addSelection('aaStart121', 'Detail') //>>> # Gui.Selection.clearSelection() -//>>> # Gui.Selection.addSelection('aaStart121','Detail') -//>>> # Gui.Selection.addSelection('aaStart121','Detail') +//>>> # Gui.Selection.addSelection('aaStart121', 'Detail') +//>>> # Gui.Selection.addSelection('aaStart121', 'Detail') //>>> # Gui.Selection.clearSelection() -//>>> # Gui.Selection.addSelection('aaStart121','Detail') +//>>> # Gui.Selection.addSelection('aaStart121', 'Detail') } return true; @@ -306,7 +306,7 @@ bool ViewProviderViewPart::onDelete(const std::vector &) auto viewSection = getViewObject()->getSectionRefs(); auto viewDetail = getViewObject()->getDetailRefs(); auto viewLeader = getViewObject()->getLeaders(); - + if (!viewSection.empty()) { bodyMessageStream << qApp->translate("Std_Delete", "You cannot delete this view because it has a section view that would become broken."); diff --git a/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp b/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp index 5ec73fc945..9303fae91c 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderViewSection.cpp @@ -56,17 +56,17 @@ ViewProviderViewSection::ViewProviderViewSection() static const char *hgroup = "Surface Hatch"; sPixmap = "TechDraw_TreeSection"; //ShowCutSurface is obsolete - use CutSurfaceDisplay - ADD_PROPERTY_TYPE(ShowCutSurface ,(true),sgroup,App::Prop_Hidden,"Show/hide the cut surface"); - ADD_PROPERTY_TYPE(CutSurfaceColor,(0.0,0.0,0.0),sgroup,App::Prop_None,"The color to shade the cut surface"); + ADD_PROPERTY_TYPE(ShowCutSurface ,(true), sgroup, App::Prop_Hidden, "Show/hide the cut surface"); + ADD_PROPERTY_TYPE(CutSurfaceColor, (0.0, 0.0, 0.0), sgroup, App::Prop_None, "The color to shade the cut surface"); //HatchCutSurface is obsolete - use CutSurfaceDisplay - ADD_PROPERTY_TYPE(HatchCutSurface ,(false),hgroup,App::Prop_Hidden,"Hatch the cut surface"); + ADD_PROPERTY_TYPE(HatchCutSurface ,(false), hgroup, App::Prop_Hidden, "Hatch the cut surface"); - ADD_PROPERTY_TYPE(HatchColor,(TechDraw::DrawHatch::prefSvgHatchColor()), - hgroup,App::Prop_None,"The color of the Svg hatch pattern"); - ADD_PROPERTY_TYPE(GeomHatchColor,(TechDraw::DrawGeomHatch::prefGeomHatchColor()), - hgroup,App::Prop_None,"The color of the Geometric hatch pattern"); + ADD_PROPERTY_TYPE(HatchColor, (TechDraw::DrawHatch::prefSvgHatchColor()), + hgroup, App::Prop_None, "The color of the Svg hatch pattern"); + ADD_PROPERTY_TYPE(GeomHatchColor, (TechDraw::DrawGeomHatch::prefGeomHatchColor()), + hgroup, App::Prop_None, "The color of the Geometric hatch pattern"); - ADD_PROPERTY_TYPE(WeightPattern,(0.1),hgroup,App::Prop_None,"GeomHatch pattern line thickness"); + ADD_PROPERTY_TYPE(WeightPattern, (0.1), hgroup, App::Prop_None, "GeomHatch pattern line thickness"); getParameters(); @@ -85,7 +85,7 @@ void ViewProviderViewSection::onChanged(const App::Property* prop) prop == &GeomHatchColor || // prop == &ShowCutSurface || prop == &CutSurfaceColor ) { - updateGraphic(); + updateGraphic(); } ViewProviderViewPart::onChanged(prop); @@ -143,10 +143,10 @@ void ViewProviderViewSection::getParameters() // App::Color hatchColor = App::Color((uint32_t) hGrp->GetUnsigned("SectionHatchColor", 0x00000000)); // HatchColor.setValue(hatchColor); - + hGrp = App::GetApplication().GetUserParameter() - .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT"); - double lineWeight = hGrp->GetFloat("GeomWeight",0.1); + .GetGroup("BaseApp")->GetGroup("Preferences")->GetGroup("Mod/TechDraw/PAT"); + double lineWeight = hGrp->GetFloat("GeomWeight", 0.1); WeightPattern.setValue(lineWeight); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp index 5ee07c3494..f6e63e1f91 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp +++ b/src/Mod/TechDraw/Gui/ViewProviderWeld.cpp @@ -52,11 +52,11 @@ ViewProviderWeld::ViewProviderWeld() sPixmap = "actions/TechDraw_WeldSymbol"; static const char *group = "Text"; - ADD_PROPERTY_TYPE(Font, (prefFontName().c_str()),group,App::Prop_None, "The name of the font to use"); + ADD_PROPERTY_TYPE(Font, (prefFontName().c_str()), group, App::Prop_None, "The name of the font to use"); ADD_PROPERTY_TYPE(FontSize, (prefFontSize()), group, - (App::PropertyType)(App::Prop_None),"Tail text size"); + (App::PropertyType)(App::Prop_None), "Tail text size"); ADD_PROPERTY_TYPE(TileFontSize, (prefFontSize() * prefTileTextAdjust()), group, - (App::PropertyType)(App::Prop_None),"Text size on individual symbol tiles"); + (App::PropertyType)(App::Prop_None), "Text size on individual symbol tiles"); } ViewProviderWeld::~ViewProviderWeld() @@ -94,7 +94,7 @@ std::vector ViewProviderWeld::claimChildren() const bool ViewProviderWeld::setEdit(int ModNum) { -// Base::Console().Message("VPW::setEdit(%d)\n",ModNum); +// Base::Console().Message("VPW::setEdit(%d)\n", ModNum); if (ModNum != ViewProvider::Default ) { return ViewProviderDrawingView::setEdit(ModNum); } diff --git a/src/Mod/TechDraw/Gui/ViewProviderWeld.h b/src/Mod/TechDraw/Gui/ViewProviderWeld.h index e3f3382e71..5aa3b5dced 100644 --- a/src/Mod/TechDraw/Gui/ViewProviderWeld.h +++ b/src/Mod/TechDraw/Gui/ViewProviderWeld.h @@ -62,7 +62,7 @@ public: double prefTileTextAdjust(); bool onDelete(const std::vector &) override; bool canDelete(App::DocumentObject* obj) const override; - + }; } // namespace TechDrawGui diff --git a/src/Mod/TechDraw/Gui/Workbench.h b/src/Mod/TechDraw/Gui/Workbench.h index 304014d2de..9c17696ed9 100644 --- a/src/Mod/TechDraw/Gui/Workbench.h +++ b/src/Mod/TechDraw/Gui/Workbench.h @@ -50,4 +50,4 @@ protected: } // namespace TechDrawGui -#endif // TECHDRAW_WORKBENCH_H +#endif // TECHDRAW_WORKBENCH_H diff --git a/src/Mod/TechDraw/Gui/ZVALUE.h b/src/Mod/TechDraw/Gui/ZVALUE.h index 711450f7df..d004943ffc 100644 --- a/src/Mod/TechDraw/Gui/ZVALUE.h +++ b/src/Mod/TechDraw/Gui/ZVALUE.h @@ -1,5 +1,5 @@ -#ifndef _TECHDRAW_ZVALUE_ -#define _TECHDRAW_ZVALUE_ +#ifndef TECHDRAW_ZVALUE_ +#define TECHDRAW_ZVALUE_ namespace ZVALUE { const int BACKGROUND = -999999; const int TEMPLATE = -1000; diff --git a/src/Mod/TechDraw/Gui/mrichtextedit.cpp b/src/Mod/TechDraw/Gui/mrichtextedit.cpp index 45bf671cae..ffc4c50e37 100644 --- a/src/Mod/TechDraw/Gui/mrichtextedit.cpp +++ b/src/Mod/TechDraw/Gui/mrichtextedit.cpp @@ -196,7 +196,7 @@ MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent) // indentation - f_indent_dec->setShortcut(QKeySequence(QString::fromUtf8("CTRL+,"))); + f_indent_dec->setShortcut(QKeySequence(QString::fromUtf8("CTRL+, "))); f_indent_inc->setShortcut(QKeySequence(QString::fromUtf8("CTRL+."))); connect(f_indent_inc, SIGNAL(clicked()), this, SLOT(increaseIndentation())); @@ -223,7 +223,7 @@ MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent) // images connect(f_image, SIGNAL(clicked()), this, SLOT(insertImage())); - + //set initial font size when editing existing text if (!textIn.isEmpty()) { //insert existing text with cursor at beginning @@ -253,7 +253,7 @@ MRichTextEdit::MRichTextEdit(QWidget *parent, QString textIn) : QWidget(parent) f_fontsize->setCurrentIndex(f_fontsize->findText(getDefFontSize())); } - + } @@ -262,7 +262,7 @@ void MRichTextEdit::textSource() { QPlainTextEdit *pte = new QPlainTextEdit(dialog); pte->setPlainText( f_textedit->toHtml() ); QGridLayout *gl = new QGridLayout(dialog); - gl->addWidget(pte,0,0,1,1); + gl->addWidget(pte, 0,0, 1,1); dialog->setWindowTitle(tr("Document source")); dialog->setMinimumWidth (400); dialog->setMinimumHeight(600); @@ -350,10 +350,10 @@ void MRichTextEdit::textStrikeout() { mergeFormatOnWordOrSelection(fmt); } -void MRichTextEdit::textSize(const QString &p) { +void MRichTextEdit::textSize(const QString &pointsAsString) { // qDebug() << "MRTE::textSize(" << p << ")"; - qreal pointSize = p.toFloat(); - if (p.toFloat() > 0) { + qreal pointSize = pointsAsString.toFloat(); + if (pointsAsString.toFloat() > 0) { QTextCharFormat fmt; fmt.setFontPointSize(pointSize); mergeFormatOnWordOrSelection(fmt); @@ -440,7 +440,7 @@ void MRichTextEdit::textStyle(int index) { void MRichTextEdit::textFgColor() { QColor col; if (Gui::DialogOptions::dontUseNativeColorDialog()){ - col = QColorDialog::getColor(f_textedit->textColor(),this, QLatin1String(""), QColorDialog::DontUseNativeDialog); + col = QColorDialog::getColor(f_textedit->textColor(), this, QLatin1String(""), QColorDialog::DontUseNativeDialog); } else { col = QColorDialog::getColor(f_textedit->textColor(), this); } @@ -462,7 +462,7 @@ void MRichTextEdit::textFgColor() { void MRichTextEdit::textBgColor() { QColor col; if (Gui::DialogOptions::dontUseNativeColorDialog()){ - col = QColorDialog::getColor(f_textedit->textBackgroundColor(),this, QLatin1String(""), QColorDialog::DontUseNativeDialog); + col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this, QLatin1String(""), QColorDialog::DontUseNativeDialog); } else { col = QColorDialog::getColor(f_textedit->textBackgroundColor(), this); } @@ -539,8 +539,8 @@ void MRichTextEdit::slotCursorPositionChanged() { QTextList *l = f_textedit->textCursor().currentList(); - if (m_lastBlockList && - (l == m_lastBlockList || + if (m_lastBlockList && + (l == m_lastBlockList || (l && m_lastBlockList && l->format().style() == m_lastBlockList->format().style()) ) ) { return; } @@ -563,24 +563,24 @@ void MRichTextEdit::slotCursorPositionChanged() { } } -void MRichTextEdit::fontChanged(const QFont &f) { +void MRichTextEdit::fontChanged(const QFont &font) { // qDebug() << "MRTE::fontChanged()"; //TODO: change this to real font selector - f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(f.pointSize()))); - f_bold->setChecked(f.bold()); - f_italic->setChecked(f.italic()); - f_underline->setChecked(f.underline()); - f_strikeout->setChecked(f.strikeOut()); - if (f.pointSize() == m_fontsize_h1) { + f_fontsize->setCurrentIndex(f_fontsize->findText(QString::number(font.pointSize()))); + f_bold->setChecked(font.bold()); + f_italic->setChecked(font.italic()); + f_underline->setChecked(font.underline()); + f_strikeout->setChecked(font.strikeOut()); + if (font.pointSize() == m_fontsize_h1) { f_paragraph->setCurrentIndex(ParagraphHeading1); - } else if (f.pointSize() == m_fontsize_h2) { + } else if (font.pointSize() == m_fontsize_h2) { f_paragraph->setCurrentIndex(ParagraphHeading2); - } else if (f.pointSize() == m_fontsize_h3) { + } else if (font.pointSize() == m_fontsize_h3) { f_paragraph->setCurrentIndex(ParagraphHeading3); - } else if (f.pointSize() == m_fontsize_h4) { + } else if (font.pointSize() == m_fontsize_h4) { f_paragraph->setCurrentIndex(ParagraphHeading4); } else { - if (f.fixedPitch() && f.family() == QString::fromUtf8("Monospace")) { + if (font.fixedPitch() && font.family() == QString::fromUtf8("Monospace")) { f_paragraph->setCurrentIndex(ParagraphMonospace); } else { f_paragraph->setCurrentIndex(ParagraphStandard); @@ -604,25 +604,25 @@ void MRichTextEdit::fontChanged(const QFont &f) { } } -void MRichTextEdit::fgColorChanged(const QColor &c) { - QSize iconSize(16,16); +void MRichTextEdit::fgColorChanged(const QColor &color) { + QSize iconSize(16, 16); QIcon fgIcon = f_fgcolor->icon(); - QPixmap fgPix = fgIcon.pixmap(iconSize,QIcon::Mode::Normal, QIcon::State::On); + QPixmap fgPix = fgIcon.pixmap(iconSize, QIcon::Mode::Normal, QIcon::State::On); QPixmap filler(iconSize); - if (c.isValid() ) { - filler.fill(c); + if (color.isValid() ) { + filler.fill(color); filler.setMask(fgPix.createMaskFromColor(Qt::transparent, Qt::MaskInColor) ); f_fgcolor->setIcon(filler); } } -void MRichTextEdit::bgColorChanged(const QColor &c) { - QSize iconSize(16,16); +void MRichTextEdit::bgColorChanged(const QColor &color) { + QSize iconSize(16, 16); QIcon bgIcon = f_bgcolor->icon(); - QPixmap bgPix = bgIcon.pixmap(iconSize,QIcon::Mode::Normal, QIcon::State::On); + QPixmap bgPix = bgIcon.pixmap(iconSize, QIcon::Mode::Normal, QIcon::State::On); QPixmap filler(iconSize); - if (c.isValid() ) { - filler.fill(c); + if (color.isValid() ) { + filler.fill(color); filler.setMask(bgPix.createMaskFromColor(Qt::transparent, Qt::MaskOutColor) ); f_bgcolor->setIcon(filler); } @@ -701,22 +701,22 @@ void MRichTextEdit::insertImage() { tr("JPEG (*.jpg);; GIF (*.gif);; PNG (*.png);; BMP (*.bmp);; All (*)")); QImage image = QImageReader(file).read(); - f_textedit->dropImage(image, + f_textedit->dropImage(image, QFileInfo(file).suffix().toUpper()); } -void MRichTextEdit::onSave(void) +void MRichTextEdit::onSave() { QString result = toHtml(); Q_EMIT saveText(result); } -void MRichTextEdit::onExit(void) +void MRichTextEdit::onExit() { Q_EMIT editorFinished(); } -void MRichTextEdit::onSelectionChanged(void) +void MRichTextEdit::onSelectionChanged() { // qDebug() << "MRTE::onSelectionChanged()"; if (hasMultipleSizes()) { @@ -732,7 +732,7 @@ void MRichTextEdit::onSelectionChanged(void) } //does selection have multiple sizes? -bool MRichTextEdit::hasMultipleSizes(void) +bool MRichTextEdit::hasMultipleSizes() { // qDebug() << "MRTE::hasMultipleSizes()"; bool result = false; @@ -747,7 +747,7 @@ bool MRichTextEdit::hasMultipleSizes(void) cursor.setPosition(currPos); QTextCharFormat fmt = cursor.charFormat(); double currSize = fmt.fontPointSize(); - QString asQS = QString::number(currSize,'f',2); + QString asQS = QString::number(currSize, 'f', 2); foundSizes.push_back(asQS); auto ret = countMap.insert(std::pair(asQS, 1)); if (!ret.second) { //already have this size @@ -758,19 +758,19 @@ bool MRichTextEdit::hasMultipleSizes(void) result = true; } } - return result; -} + return result; +} -void MRichTextEdit::setDefFontSize(int fs) +void MRichTextEdit::setDefFontSize(int fontSize) { // Base::Console().Message("MRTE::setDefFontSize(%d)\n", fs); - m_defFontSize = fs; - m_fontsize_h1 = fs + 8; - m_fontsize_h2 = fs + 6; - m_fontsize_h3 = fs + 4; - m_fontsize_h4 = fs + 2; + m_defFontSize = fontSize; + m_fontsize_h1 = fontSize + 8; + m_fontsize_h2 = fontSize + 6; + m_fontsize_h3 = fontSize + 4; + m_fontsize_h4 = fontSize + 2; - QString newSize = QString::number(fs); + QString newSize = QString::number(fontSize); f_fontsize->findText(newSize); int idx = f_fontsize->findText(newSize); if (idx > -1) { @@ -781,7 +781,7 @@ void MRichTextEdit::setDefFontSize(int fs) textSize(newSize); } -int MRichTextEdit::getDefFontSizeNum(void) +int MRichTextEdit::getDefFontSizeNum() { // Base::Console().Message("MRTE::getDefFontSizeNum()\n"); double fontSize = TechDraw::Preferences::dimFontSizeMM(); @@ -789,12 +789,12 @@ int MRichTextEdit::getDefFontSizeNum(void) //this conversion is only approximate. the factor changes for different fonts. // double mmToPts = 2.83; //theoretical value double mmToPts = 2.00; //practical value. seems to be reasonable for common fonts. - + int ptsSize = round(fontSize * mmToPts); return ptsSize; } -QString MRichTextEdit::getDefFontSize(void) +QString MRichTextEdit::getDefFontSize() { // Base::Console().Message("MRTE::getDefFontSize()\n"); QString result = QString::number(getDefFontSizeNum()); @@ -802,12 +802,12 @@ QString MRichTextEdit::getDefFontSize(void) } //not used. -void MRichTextEdit::setDefFont(QString f) +void MRichTextEdit::setDefFont(QString fontName) { - m_defFont = f; + m_defFont = fontName; } -QFont MRichTextEdit::getDefFont(void) +QFont MRichTextEdit::getDefFont() { QString family = Base::Tools::fromStdString(Preferences::labelFont()); m_defFont = family; @@ -818,12 +818,12 @@ QFont MRichTextEdit::getDefFont(void) // add a new fontSize to the list // this seems like massive overkill for integer point<->mm conversion factor -// if the conversion factor is float, will generate non-standard sizes -void MRichTextEdit::addFontSize(QString fs) +// if the conversion factor is float, will generate non-standard sizes +void MRichTextEdit::addFontSize(QString fontSize) { // Base::Console().Message("MRTE::addFontSize(%s)\n", qPrintable(fs)); QStringList newList; - int fsVal = fs.toInt(); + int fsVal = fontSize.toInt(); int size = f_fontsize->count(); bool added = false; for (int i = 0; i < size; i++) { @@ -839,13 +839,13 @@ void MRichTextEdit::addFontSize(QString fs) newList << item; added = true; } else { //item > fs, add both - newList << fs; - newList << item; + newList << fontSize; + newList << item; added = true; } } if (!added) { //bigger than all choices, add to end of list - newList << fs; + newList << fontSize; } f_fontsize->clear(); f_fontsize->addItems(newList); diff --git a/src/Mod/TechDraw/Gui/mrichtextedit.h b/src/Mod/TechDraw/Gui/mrichtextedit.h index d38cdae4db..27c59c7fe3 100644 --- a/src/Mod/TechDraw/Gui/mrichtextedit.h +++ b/src/Mod/TechDraw/Gui/mrichtextedit.h @@ -26,8 +26,8 @@ ********************************/ -#ifndef _MRICHTEXTEDIT_H_ -#define _MRICHTEXTEDIT_H_ +#ifndef MRICHTEXTEDIT_H_ +#define MRICHTEXTEDIT_H_ #include @@ -40,31 +40,52 @@ */ class MRichTextEdit : public QWidget, protected Ui::MRichTextEdit { Q_OBJECT - public: + +public: MRichTextEdit(QWidget *parent = nullptr, QString textIn = QString() ); + ~MRichTextEdit() = default; QString toPlainText() const { return f_textedit->toPlainText(); } QString toHtml() const; QTextDocument *document() { return f_textedit->document(); } QTextCursor textCursor() const { return f_textedit->textCursor(); } void setTextCursor(const QTextCursor& cursor) { f_textedit->setTextCursor(cursor); } - void setMaxWidth(double w); - void setDefFontSize(int fs); - void setDefFont(QString f); - QString getDefFontSize(void); - int getDefFontSizeNum(void); - QFont getDefFont(void); - - public Q_SLOTS: + void setDefFontSize(int fontSize); + void setDefFont(QString fontName); + QString getDefFontSize(); + int getDefFontSizeNum(); + QFont getDefFont(); + +public Q_SLOTS: void setText(const QString &text); Q_SIGNALS: void saveText(QString revText); void editorFinished(); - protected Q_SLOTS: - void onSave(void); - void onExit(void); +protected: + void mergeFormatOnWordOrSelection(const QTextCharFormat &format); + void fontChanged(const QFont &font); + void fgColorChanged(const QColor &color); + void bgColorChanged(const QColor &color); + void list(bool checked, QTextListFormat::Style style); + void indent(int delta); + void focusInEvent(QFocusEvent *event); + void keyPressEvent(QKeyEvent *event); + bool hasMultipleSizes(); + + void addFontSize(QString fontSize); + + enum ParagraphItems { ParagraphStandard = 0, + ParagraphHeading1, + ParagraphHeading2, + ParagraphHeading3, + ParagraphHeading4, + ParagraphMonospace }; + +protected Q_SLOTS: + void onSave(); + void onExit(); void setPlainText(const QString &text) { f_textedit->setPlainText(text); } void setHtml(const QString &text) { f_textedit->setHtml(text); } void textRemoveFormat(); @@ -73,7 +94,7 @@ Q_SIGNALS: void textUnderline(); void textStrikeout(); void textItalic(); - void textSize(const QString &p); + void textSize(const QString &pointsAsString); void textLink(bool checked); void textStyle(int index); void textFgColor(); @@ -89,35 +110,17 @@ Q_SIGNALS: void textSource(); void onSelectionChanged(); - protected: - void mergeFormatOnWordOrSelection(const QTextCharFormat &format); - void fontChanged(const QFont &f); - void fgColorChanged(const QColor &c); - void bgColorChanged(const QColor &c); - void list(bool checked, QTextListFormat::Style style); - void indent(int delta); - void focusInEvent(QFocusEvent *event); - void keyPressEvent(QKeyEvent *event); - bool hasMultipleSizes(void); - - void addFontSize(QString fs); - +private: QStringList m_paragraphItems; int m_fontsize_h1; int m_fontsize_h2; int m_fontsize_h3; int m_fontsize_h4; - enum ParagraphItems { ParagraphStandard = 0, - ParagraphHeading1, - ParagraphHeading2, - ParagraphHeading3, - ParagraphHeading4, - ParagraphMonospace }; - QPointer m_lastBlockList; int m_defFontSize; QString m_defFont; + }; #endif diff --git a/src/Mod/TechDraw/Gui/mtextedit.cpp b/src/Mod/TechDraw/Gui/mtextedit.cpp index a94e0beae3..46b23476aa 100644 --- a/src/Mod/TechDraw/Gui/mtextedit.cpp +++ b/src/Mod/TechDraw/Gui/mtextedit.cpp @@ -96,7 +96,7 @@ void MTextEdit::dropImage(const QImage& image, const QString& format) { QTextImageFormat imageFormat; imageFormat.setWidth ( image.width() ); imageFormat.setHeight ( image.height() ); - imageFormat.setName ( QString::fromLatin1("data:image/%1;base64,%2") + imageFormat.setName ( QString::fromLatin1("data:image/%1;base64, %2") .arg(QString::fromLatin1("%1.%2").arg(rand()).arg(format)) .arg(QString::fromLatin1(base64l.data())) ); diff --git a/src/Mod/TechDraw/Gui/mtextedit.h b/src/Mod/TechDraw/Gui/mtextedit.h index 398ca2e41d..eb6737c2b1 100644 --- a/src/Mod/TechDraw/Gui/mtextedit.h +++ b/src/Mod/TechDraw/Gui/mtextedit.h @@ -20,8 +20,8 @@ ** ** $QT_END_LICENSE$ */ -#ifndef _MTEXTEDIT_H_ -#define _MTEXTEDIT_H_ +#ifndef MTEXTEDIT_H_ +#define MTEXTEDIT_H_ #include