From cbd0140dcd15371b76dfc57a128aabe2ca6f948e Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 17:22:13 +0100 Subject: [PATCH 01/26] [TD] Task*, part 2/2: remove unused includes - also some sorting - also take care of PreCompiled.h --- src/Mod/TechDraw/App/PreCompiled.h | 4 --- src/Mod/TechDraw/Gui/PreCompiled.h | 3 ++ src/Mod/TechDraw/Gui/TaskBalloon.cpp | 21 +++-------- src/Mod/TechDraw/Gui/TaskBalloon.h | 4 +-- src/Mod/TechDraw/Gui/TaskCenterLine.cpp | 5 --- src/Mod/TechDraw/Gui/TaskCenterLine.h | 4 +-- src/Mod/TechDraw/Gui/TaskComplexSection.cpp | 27 ++++---------- src/Mod/TechDraw/Gui/TaskComplexSection.h | 4 +-- src/Mod/TechDraw/Gui/TaskCosVertex.cpp | 28 +++++---------- src/Mod/TechDraw/Gui/TaskCosVertex.h | 4 +-- src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp | 27 +++----------- src/Mod/TechDraw/Gui/TaskCosmeticLine.h | 4 +-- src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp | 37 +++----------------- src/Mod/TechDraw/Gui/TaskCustomizeFormat.h | 3 +- src/Mod/TechDraw/Gui/TaskDetail.cpp | 32 +++++------------ src/Mod/TechDraw/Gui/TaskDetail.h | 3 +- src/Mod/TechDraw/Gui/TaskDimension.cpp | 25 ++++--------- src/Mod/TechDraw/Gui/TaskDimension.h | 4 +-- src/Mod/TechDraw/Gui/TaskGeomHatch.cpp | 20 +++-------- src/Mod/TechDraw/Gui/TaskGeomHatch.h | 3 +- src/Mod/TechDraw/Gui/TaskHatch.cpp | 21 ++++------- src/Mod/TechDraw/Gui/TaskHatch.h | 8 ++--- src/Mod/TechDraw/Gui/TaskLeaderLine.cpp | 25 +++++-------- src/Mod/TechDraw/Gui/TaskLeaderLine.h | 4 +-- src/Mod/TechDraw/Gui/TaskLineDecor.cpp | 25 ++++--------- src/Mod/TechDraw/Gui/TaskLineDecor.h | 4 +-- src/Mod/TechDraw/Gui/TaskLinkDim.cpp | 19 ++++------ src/Mod/TechDraw/Gui/TaskLinkDim.h | 4 +-- src/Mod/TechDraw/Gui/TaskProjection.cpp | 9 ++--- src/Mod/TechDraw/Gui/TaskProjection.h | 5 ++- 30 files changed, 107 insertions(+), 279 deletions(-) diff --git a/src/Mod/TechDraw/App/PreCompiled.h b/src/Mod/TechDraw/App/PreCompiled.h index 10c619664c..5ac70f8e99 100644 --- a/src/Mod/TechDraw/App/PreCompiled.h +++ b/src/Mod/TechDraw/App/PreCompiled.h @@ -33,17 +33,13 @@ // standard #include -#include -#include #include #include - #include #include #include #include #include -#include #include #include #include diff --git a/src/Mod/TechDraw/Gui/PreCompiled.h b/src/Mod/TechDraw/Gui/PreCompiled.h index 4836a34edc..36c2ebf12f 100644 --- a/src/Mod/TechDraw/Gui/PreCompiled.h +++ b/src/Mod/TechDraw/Gui/PreCompiled.h @@ -59,6 +59,7 @@ #endif #include #include +#include #include #include #include @@ -66,8 +67,10 @@ // OpenCasCade #include +#include #include #include +#include // Open Inventor #include diff --git a/src/Mod/TechDraw/Gui/TaskBalloon.cpp b/src/Mod/TechDraw/Gui/TaskBalloon.cpp index bf303cf4a1..eeb6cd9198 100644 --- a/src/Mod/TechDraw/Gui/TaskBalloon.cpp +++ b/src/Mod/TechDraw/Gui/TaskBalloon.cpp @@ -22,33 +22,22 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include +# include #endif // #ifndef _PreComp_ +#include #include - -#include #include #include #include -#include -#include - -#include -#include -#include - -#include -#include -#include +#include "TaskBalloon.h" +#include "ui_TaskBalloon.h" #include "DrawGuiUtil.h" #include "QGIViewBalloon.h" #include "ViewProviderBalloon.h" -#include "TaskBalloon.h" -#include "ui_TaskBalloon.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskBalloon.h b/src/Mod/TechDraw/Gui/TaskBalloon.h index 6503604165..29b0b3cf79 100644 --- a/src/Mod/TechDraw/Gui/TaskBalloon.h +++ b/src/Mod/TechDraw/Gui/TaskBalloon.h @@ -24,10 +24,10 @@ #ifndef GUI_TASKVIEW_TASKBALLOON_H #define GUI_TASKVIEW_TASKBALLOON_H -#include - #include #include +#include + namespace TechDrawGui { diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp index 8ee8dde616..53ff1de0b1 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.cpp @@ -28,16 +28,11 @@ #include #include #include -#include #include -#include -#include #include -#include #include #include #include -#include #include #include #include diff --git a/src/Mod/TechDraw/Gui/TaskCenterLine.h b/src/Mod/TechDraw/Gui/TaskCenterLine.h index 54684088f9..64fbafdf18 100644 --- a/src/Mod/TechDraw/Gui/TaskCenterLine.h +++ b/src/Mod/TechDraw/Gui/TaskCenterLine.h @@ -23,11 +23,9 @@ #ifndef TECHDRAWGUI_TASKCENTERLINE_H #define TECHDRAWGUI_TASKCENTERLINE_H -#include - #include #include - +#include #include diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp index d8cf2f37e8..712daa90b2 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.cpp +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.cpp @@ -21,49 +21,34 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ +# include +# include #endif // #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 "DrawGuiUtil.h" #include "Widgets/CompassWidget.h" #include "Widgets/VectorEditWidget.h" #include "TaskComplexSection.h" +#include "ui_TaskComplexSection.h" +#include "DrawGuiUtil.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskComplexSection.h b/src/Mod/TechDraw/Gui/TaskComplexSection.h index f604805e6b..ae667bb81c 100644 --- a/src/Mod/TechDraw/Gui/TaskComplexSection.h +++ b/src/Mod/TechDraw/Gui/TaskComplexSection.h @@ -23,13 +23,13 @@ #ifndef TECHDRAWGUI_TASKCOMPLEXSECTION_H #define TECHDRAWGUI_TASKCOMPLEXSECTION_H -#include - #include #include #include #include +#include + namespace App { diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index 099dd645c4..c814538fe4 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -21,46 +21,36 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include -#include +# include +# include #endif // #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 "QGSPage.h" -#include "QGIView.h" +#include "ui_TaskCosVertex.h" +#include "TaskCosVertex.h" #include "MDIViewPage.h" -#include "ViewProviderPage.h" +#include "QGIView.h" +#include "QGSPage.h" #include "QGTracker.h" #include "Rez.h" +#include "ViewProviderPage.h" -#include "TaskCosVertex.h" using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.h b/src/Mod/TechDraw/Gui/TaskCosVertex.h index 8700b4cac9..a72810109e 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.h +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.h @@ -23,12 +23,12 @@ #ifndef TECHDRAWGUI_TASKCOSVERTEX_H #define TECHDRAWGUI_TASKCOSVERTEX_H -#include +#include "QGTracker.h" #include #include +#include -#include "QGTracker.h" namespace TechDraw { diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp b/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp index d8bf2d40b7..2112099c1e 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosmeticLine.cpp @@ -21,42 +21,25 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include -#include -#include -#include +# include +# include #endif -#include - #include -#include -#include - -#include #include #include -#include #include -#include #include -#include -#include - -#include #include -#include #include -#include #include +#include -#include - +#include "ui_TaskCosmeticLine.h" #include "TaskCosmeticLine.h" + using namespace Gui; using namespace TechDraw; using namespace TechDrawGui; diff --git a/src/Mod/TechDraw/Gui/TaskCosmeticLine.h b/src/Mod/TechDraw/Gui/TaskCosmeticLine.h index 121c5c46bd..be589a6142 100644 --- a/src/Mod/TechDraw/Gui/TaskCosmeticLine.h +++ b/src/Mod/TechDraw/Gui/TaskCosmeticLine.h @@ -23,11 +23,11 @@ #ifndef TECHDRAWGUI_TASKCOSMETICLINE_H #define TECHDRAWGUI_TASKCOSMETICLINE_H -#include - #include #include #include +#include + namespace TechDraw { diff --git a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp index c7006e36f4..cf1160e610 100644 --- a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp +++ b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.cpp @@ -21,47 +21,20 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include -#include -#include -#include -#include -#include +# include #endif -#include -#include -#include - #include - -#include +#include #include #include -#include -#include -#include -#include -#include -#include - -#include #include -#include +#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 "TaskCustomizeFormat.h" +#include "ui_TaskCustomizeFormat.h" -# include "TaskCustomizeFormat.h" using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h index b206392704..9b8dc3e0d7 100644 --- a/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h +++ b/src/Mod/TechDraw/Gui/TaskCustomizeFormat.h @@ -23,10 +23,9 @@ #ifndef TECHDRAWGUI_TASKCUSTOMIZEFORMAT_H #define TECHDRAWGUI_TASKCUSTOMIZEFORMAT_H -#include - #include #include +#include namespace App { diff --git a/src/Mod/TechDraw/Gui/TaskDetail.cpp b/src/Mod/TechDraw/Gui/TaskDetail.cpp index 546328bad3..0302e90333 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.cpp +++ b/src/Mod/TechDraw/Gui/TaskDetail.cpp @@ -22,45 +22,29 @@ #include "PreCompiled.h" -#ifndef _PreComp_ -#include -#include -#endif // #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 "QGSPage.h" -#include "QGIView.h" -#include "QGIGhostHighlight.h" -#include "ViewProviderPage.h" -#include "Rez.h" - +#include "ui_TaskDetail.h" #include "TaskDetail.h" +#include "QGIGhostHighlight.h" +#include "QGSPage.h" +#include "Rez.h" +#include "ViewProviderPage.h" + using namespace TechDrawGui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskDetail.h b/src/Mod/TechDraw/Gui/TaskDetail.h index 6847a7be29..0fedb3d579 100644 --- a/src/Mod/TechDraw/Gui/TaskDetail.h +++ b/src/Mod/TechDraw/Gui/TaskDetail.h @@ -23,11 +23,10 @@ #ifndef TECHDRAWGUI_TASKDETAIL_H #define TECHDRAWGUI_TASKDETAIL_H -#include - #include #include #include +#include //TODO: make this a proper enum diff --git a/src/Mod/TechDraw/Gui/TaskDimension.cpp b/src/Mod/TechDraw/Gui/TaskDimension.cpp index 2afc1fdebd..b3de94e460 100644 --- a/src/Mod/TechDraw/Gui/TaskDimension.cpp +++ b/src/Mod/TechDraw/Gui/TaskDimension.cpp @@ -21,37 +21,26 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include +# include +# include #endif // #ifndef _PreComp_ - -#include - -#include +#include #include #include #include #include #include #include -#include - -#include -#include -#include - -#include -#include #include -#include +#include -#include "QGIViewDimension.h" -#include "ViewProviderDimension.h" #include "ui_TaskDimension.h" #include "TaskDimension.h" +#include "QGIViewDimension.h" +#include "ViewProviderDimension.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskDimension.h b/src/Mod/TechDraw/Gui/TaskDimension.h index fdbc163e2a..401cf82c9d 100644 --- a/src/Mod/TechDraw/Gui/TaskDimension.h +++ b/src/Mod/TechDraw/Gui/TaskDimension.h @@ -23,10 +23,10 @@ #ifndef GUI_TASKVIEW_TASKDIMENSION_H #define GUI_TASKVIEW_TASKDIMENSION_H -#include - #include #include +#include + namespace TechDrawGui { diff --git a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp index c9686611ba..f767c17769 100644 --- a/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskGeomHatch.cpp @@ -21,33 +21,23 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include +# include #endif // #ifndef _PreComp_ +#include #include #include - -#include #include #include -#include -#include #include - -#include -#include -#include - -#include #include #include -#include -#include "ViewProviderGeomHatch.h" #include "TaskGeomHatch.h" -#include +#include "ui_TaskGeomHatch.h" +#include "ViewProviderGeomHatch.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskGeomHatch.h b/src/Mod/TechDraw/Gui/TaskGeomHatch.h index d2d9742489..6bc3143efe 100644 --- a/src/Mod/TechDraw/Gui/TaskGeomHatch.h +++ b/src/Mod/TechDraw/Gui/TaskGeomHatch.h @@ -23,10 +23,9 @@ #ifndef GUI_TASKVIEW_TASKGEOMHATCH_H #define GUI_TASKVIEW_TASKGEOMHATCH_H -#include - #include #include +#include namespace App diff --git a/src/Mod/TechDraw/Gui/TaskHatch.cpp b/src/Mod/TechDraw/Gui/TaskHatch.cpp index 68fdeb7fed..d66354d95b 100644 --- a/src/Mod/TechDraw/Gui/TaskHatch.cpp +++ b/src/Mod/TechDraw/Gui/TaskHatch.cpp @@ -22,35 +22,28 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include +# include #endif // #ifndef _PreComp_ +#include +#include #include #include #include - #include #include #include #include -#include #include - -#include -#include -#include - #include -#include -#include #include +#include -#include "PreferencesGui.h" -#include "ViewProviderHatch.h" #include "TaskHatch.h" -#include +#include "ui_TaskHatch.h" +#include "ViewProviderHatch.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskHatch.h b/src/Mod/TechDraw/Gui/TaskHatch.h index d5c234f3a8..b72d3c5dbe 100644 --- a/src/Mod/TechDraw/Gui/TaskHatch.h +++ b/src/Mod/TechDraw/Gui/TaskHatch.h @@ -24,14 +24,12 @@ #ifndef GUI_TASKVIEW_TASKHATCH_H #define GUI_TASKVIEW_TASKHATCH_H -#include - -#include #include #include - +#include #include -#include + +#include "ui_TaskHatch.h" class Ui_TaskHatch; diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index 1a76069e62..534fa353e5 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -21,11 +21,9 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include -#include +# include +# include #endif #include @@ -34,34 +32,27 @@ #include #include #include -#include #include #include -#include #include -#include #include #include #include -#include #include #include #include "TaskLeaderLine.h" #include "ui_TaskLeaderLine.h" #include "DrawGuiUtil.h" -#include "PreferencesGui.h" -#include "QGSPage.h" -#include "QGVPage.h" -#include "QGIView.h" -#include "QGIPrimPath.h" #include "MDIViewPage.h" -#include "ViewProviderPage.h" -#include "ViewProviderLeader.h" -#include "QGTracker.h" -#include "QGEPath.h" +#include "PreferencesGui.h" #include "QGILeaderLine.h" +#include "QGIView.h" +#include "QGSPage.h" +#include "QGTracker.h" #include "Rez.h" +#include "ViewProviderLeader.h" +#include "ViewProviderPage.h" using namespace Gui; diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.h b/src/Mod/TechDraw/Gui/TaskLeaderLine.h index 4cdfea980b..1cfd02252d 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.h +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.h @@ -23,13 +23,13 @@ #ifndef TECHDRAWGUI_TASKTEXTLEADER_H #define TECHDRAWGUI_TASKTEXTLEADER_H -#include +#include "QGTracker.h" #include #include #include +#include -#include "QGTracker.h" namespace TechDraw { diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp index 450f2ea874..c98752e221 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.cpp +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.cpp @@ -21,39 +21,28 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include +# include #endif // #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 "TaskLineDecor.h" +#include "ui_TaskLineDecor.h" +#include "ui_TaskRestoreLines.h" #include "QGIView.h" #include "ViewProviderViewPart.h" -#include "TaskLineDecor.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskLineDecor.h b/src/Mod/TechDraw/Gui/TaskLineDecor.h index 99c5fb107c..9c58640c1a 100644 --- a/src/Mod/TechDraw/Gui/TaskLineDecor.h +++ b/src/Mod/TechDraw/Gui/TaskLineDecor.h @@ -23,10 +23,9 @@ #ifndef GUI_TASKVIEW_TASKLINEDECOR_H #define GUI_TASKVIEW_TASKLINEDECOR_H -#include - #include #include +#include namespace App @@ -34,7 +33,6 @@ namespace App class DocumentObject; } - namespace TechDrawGui { diff --git a/src/Mod/TechDraw/Gui/TaskLinkDim.cpp b/src/Mod/TechDraw/Gui/TaskLinkDim.cpp index 1ba57348e7..0a7b92ef12 100644 --- a/src/Mod/TechDraw/Gui/TaskLinkDim.cpp +++ b/src/Mod/TechDraw/Gui/TaskLinkDim.cpp @@ -21,12 +21,13 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include +# include +# include #endif // #ifndef _PreComp_ +#include +#include #include #include @@ -35,20 +36,12 @@ #include #include #include - -#include -#include -#include - -#include - #include -#include #include -#include #include "TaskLinkDim.h" -#include +#include "ui_TaskLinkDim.h" + using namespace Gui; using namespace TechDraw; diff --git a/src/Mod/TechDraw/Gui/TaskLinkDim.h b/src/Mod/TechDraw/Gui/TaskLinkDim.h index dec6a69e1c..b98a538015 100644 --- a/src/Mod/TechDraw/Gui/TaskLinkDim.h +++ b/src/Mod/TechDraw/Gui/TaskLinkDim.h @@ -23,10 +23,10 @@ #ifndef GUI_TASKVIEW_TASKLINKDIM_H #define GUI_TASKVIEW_TASKLINKDIM_H -#include - #include #include +#include + class QTreeWidgetItem; diff --git a/src/Mod/TechDraw/Gui/TaskProjection.cpp b/src/Mod/TechDraw/Gui/TaskProjection.cpp index 487cde5744..9c2e2aa227 100644 --- a/src/Mod/TechDraw/Gui/TaskProjection.cpp +++ b/src/Mod/TechDraw/Gui/TaskProjection.cpp @@ -23,29 +23,24 @@ //migrated to TechDraw workbench 2022-01-26 by Wandererfan #include "PreCompiled.h" - #ifndef _PreComp_ -# include # include #endif - -#include - #include #include #include -#include #include #include +#include #include #include - #include #include "TaskProjection.h" #include "ui_TaskProjection.h" + using namespace TechDrawGui; /* TRANSLATOR TechDrawGui::TaskProjection */ diff --git a/src/Mod/TechDraw/Gui/TaskProjection.h b/src/Mod/TechDraw/Gui/TaskProjection.h index 19c7288575..7558de6857 100644 --- a/src/Mod/TechDraw/Gui/TaskProjection.h +++ b/src/Mod/TechDraw/Gui/TaskProjection.h @@ -22,16 +22,15 @@ //this file originally part of Drawing workbench //migrated to TechDraw workbench 2022-01-26 by Wandererfan - #ifndef TECHDRAWGUI_TASKDIALOG #define TECHDRAWGUI_TASKDIALOG -#include - #include #include #include +#include + class QCheckBox; From 423c3305346717a1ef0e5fbd842748275963b8d6 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 18:35:59 +0100 Subject: [PATCH 02/26] [Path] improve PreCompiled.h handling --- src/Mod/Path/App/Area.cpp | 2 +- src/Mod/Path/App/PreCompiled.h | 26 ++------------- src/Mod/Path/Gui/AppPathGuiPy.cpp | 2 ++ src/Mod/Path/Gui/Command.cpp | 1 + src/Mod/Path/Gui/DlgProcessorChooser.cpp | 1 + src/Mod/Path/Gui/DlgProcessorChooser.h | 1 + src/Mod/Path/Gui/PreCompiled.h | 33 ++++++++----------- src/Mod/Path/Gui/TaskDlgPathCompound.cpp | 1 + src/Mod/Path/Gui/TaskDlgPathCompound.h | 2 ++ src/Mod/Path/Gui/ViewProviderArea.cpp | 3 ++ src/Mod/Path/Gui/ViewProviderArea.h | 2 ++ src/Mod/Path/Gui/ViewProviderPath.cpp | 1 + src/Mod/Path/Gui/ViewProviderPath.h | 2 ++ src/Mod/Path/Gui/ViewProviderPathCompound.cpp | 2 ++ src/Mod/Path/Gui/ViewProviderPathCompound.h | 4 ++- src/Mod/Path/Gui/ViewProviderPathShape.cpp | 2 ++ src/Mod/Path/Gui/ViewProviderPathShape.h | 4 ++- src/Mod/Path/PathSimulator/App/PreCompiled.h | 19 ----------- 18 files changed, 43 insertions(+), 65 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index 92494e4d48..e9e4700257 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -45,8 +45,8 @@ # include # include # include -# include # include +# include # include # include # include diff --git a/src/Mod/Path/App/PreCompiled.h b/src/Mod/Path/App/PreCompiled.h index b510b2868c..11fc11b120 100644 --- a/src/Mod/Path/App/PreCompiled.h +++ b/src/Mod/Path/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef PATH_PRECOMPILED_H #define PATH_PRECOMPILED_H @@ -44,30 +43,19 @@ #ifdef _PreComp_ // standard -#include -#include -#include #include -#include #include -#include #include -#include #include #include #include // Boost -#include #include -#include -#include -#include #include #include #include #include -#include #include //OCC @@ -77,32 +65,23 @@ #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 -#include #include #include #include @@ -115,7 +94,6 @@ #include #include #include -#include #include #include #include diff --git a/src/Mod/Path/Gui/AppPathGuiPy.cpp b/src/Mod/Path/Gui/AppPathGuiPy.cpp index 5b336d208d..63f6066b1f 100644 --- a/src/Mod/Path/Gui/AppPathGuiPy.cpp +++ b/src/Mod/Path/Gui/AppPathGuiPy.cpp @@ -23,6 +23,8 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include + # include # include #endif diff --git a/src/Mod/Path/Gui/Command.cpp b/src/Mod/Path/Gui/Command.cpp index 0d817c5c74..2ee14b9d5e 100644 --- a/src/Mod/Path/Gui/Command.cpp +++ b/src/Mod/Path/Gui/Command.cpp @@ -22,6 +22,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include #endif diff --git a/src/Mod/Path/Gui/DlgProcessorChooser.cpp b/src/Mod/Path/Gui/DlgProcessorChooser.cpp index 273af7465e..f316f53919 100644 --- a/src/Mod/Path/Gui/DlgProcessorChooser.cpp +++ b/src/Mod/Path/Gui/DlgProcessorChooser.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include #endif diff --git a/src/Mod/Path/Gui/DlgProcessorChooser.h b/src/Mod/Path/Gui/DlgProcessorChooser.h index 2cb7ae3021..5a36c3cd82 100644 --- a/src/Mod/Path/Gui/DlgProcessorChooser.h +++ b/src/Mod/Path/Gui/DlgProcessorChooser.h @@ -23,6 +23,7 @@ #ifndef PATH_DlgProcessorChooser_H #define PATH_DlgProcessorChooser_H +#include #include diff --git a/src/Mod/Path/Gui/PreCompiled.h b/src/Mod/Path/Gui/PreCompiled.h index 7a7399fb4b..f110cd084c 100644 --- a/src/Mod/Path/Gui/PreCompiled.h +++ b/src/Mod/Path/Gui/PreCompiled.h @@ -46,29 +46,16 @@ #ifdef _PreComp_ -// boost -#include - -// standard -#include -#include -#include - // STL #include -#include -#include -#include -#include -#include -#include -#include -#include #ifdef FC_OS_WIN32 # include #endif +// boost +#include + // OCC #include @@ -78,9 +65,17 @@ #endif // all of Inventor -#ifndef __InventorAll__ -# include -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif //_PreComp_ diff --git a/src/Mod/Path/Gui/TaskDlgPathCompound.cpp b/src/Mod/Path/Gui/TaskDlgPathCompound.cpp index a5ff799522..9f00d2ae93 100644 --- a/src/Mod/Path/Gui/TaskDlgPathCompound.cpp +++ b/src/Mod/Path/Gui/TaskDlgPathCompound.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include #endif diff --git a/src/Mod/Path/Gui/TaskDlgPathCompound.h b/src/Mod/Path/Gui/TaskDlgPathCompound.h index 0473b112ae..dae78306a5 100644 --- a/src/Mod/Path/Gui/TaskDlgPathCompound.h +++ b/src/Mod/Path/Gui/TaskDlgPathCompound.h @@ -23,6 +23,8 @@ #ifndef PATHGUI_TaskDlgPathCompound_H #define PATHGUI_TaskDlgPathCompound_H +#include + #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderArea.cpp b/src/Mod/Path/Gui/ViewProviderArea.cpp index 8a2cca3282..11768c59e0 100644 --- a/src/Mod/Path/Gui/ViewProviderArea.cpp +++ b/src/Mod/Path/Gui/ViewProviderArea.cpp @@ -21,6 +21,9 @@ ****************************************************************************/ #include "PreCompiled.h" +#ifndef _PreComp_ +# include +#endif #include #include diff --git a/src/Mod/Path/Gui/ViewProviderArea.h b/src/Mod/Path/Gui/ViewProviderArea.h index 7da299d4b5..5bde542864 100644 --- a/src/Mod/Path/Gui/ViewProviderArea.h +++ b/src/Mod/Path/Gui/ViewProviderArea.h @@ -23,6 +23,8 @@ #ifndef PATH_ViewProviderArea_H #define PATH_ViewProviderArea_H +#include + #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index 63b24a4bae..3ca37dfbd5 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ +# include # include # include diff --git a/src/Mod/Path/Gui/ViewProviderPath.h b/src/Mod/Path/Gui/ViewProviderPath.h index 9b5b4c1762..7f39f6fc31 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.h +++ b/src/Mod/Path/Gui/ViewProviderPath.h @@ -23,6 +23,8 @@ #ifndef PATH_ViewProviderPath_H #define PATH_ViewProviderPath_H +#include + #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathCompound.cpp b/src/Mod/Path/Gui/ViewProviderPathCompound.cpp index a6d72afa0e..facc075bf4 100644 --- a/src/Mod/Path/Gui/ViewProviderPathCompound.cpp +++ b/src/Mod/Path/Gui/ViewProviderPathCompound.cpp @@ -22,6 +22,8 @@ #include "PreCompiled.h" +#include + #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathCompound.h b/src/Mod/Path/Gui/ViewProviderPathCompound.h index 0930cf8b8e..0b14f229dd 100644 --- a/src/Mod/Path/Gui/ViewProviderPathCompound.h +++ b/src/Mod/Path/Gui/ViewProviderPathCompound.h @@ -20,12 +20,14 @@ * * ***************************************************************************/ - #ifndef PATH_ViewProviderPathCompound_H #define PATH_ViewProviderPathCompound_H +#include + #include "ViewProviderPath.h" + namespace PathGui { diff --git a/src/Mod/Path/Gui/ViewProviderPathShape.cpp b/src/Mod/Path/Gui/ViewProviderPathShape.cpp index cb0b45cdf3..6b735c6ea9 100644 --- a/src/Mod/Path/Gui/ViewProviderPathShape.cpp +++ b/src/Mod/Path/Gui/ViewProviderPathShape.cpp @@ -22,6 +22,8 @@ #include "PreCompiled.h" +#include + #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathShape.h b/src/Mod/Path/Gui/ViewProviderPathShape.h index 8e60a3b7d8..55a73ce9d8 100644 --- a/src/Mod/Path/Gui/ViewProviderPathShape.h +++ b/src/Mod/Path/Gui/ViewProviderPathShape.h @@ -20,12 +20,14 @@ * * ***************************************************************************/ - #ifndef PATH_ViewProviderPathShape_H #define PATH_ViewProviderPathShape_H +#include + #include "ViewProviderPath.h" + namespace PathGui { diff --git a/src/Mod/Path/PathSimulator/App/PreCompiled.h b/src/Mod/Path/PathSimulator/App/PreCompiled.h index c8463f6304..a1dfa37453 100644 --- a/src/Mod/Path/PathSimulator/App/PreCompiled.h +++ b/src/Mod/Path/PathSimulator/App/PreCompiled.h @@ -40,29 +40,10 @@ #ifdef _PreComp_ -// standard -#include -#include -#include - // STL #include -#include -#include -#include -#include -#include -#include -#include -#include #include -// Boost -#include - -// Xerces -#include - #endif //_PreComp_ #endif From 960ace8034e395ccd08d4b2d6721b7e686adea4a Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 18:36:47 +0100 Subject: [PATCH 03/26] [Path] improve PreCompiled.h handling --- src/Mod/Path/App/Area.cpp | 2 +- src/Mod/Path/App/PreCompiled.h | 26 +++++++++++++-- src/Mod/Path/Gui/AppPathGuiPy.cpp | 2 -- src/Mod/Path/Gui/Command.cpp | 1 - src/Mod/Path/Gui/DlgProcessorChooser.cpp | 1 - src/Mod/Path/Gui/DlgProcessorChooser.h | 1 - src/Mod/Path/Gui/PreCompiled.h | 33 +++++++++++-------- src/Mod/Path/Gui/TaskDlgPathCompound.cpp | 1 - src/Mod/Path/Gui/TaskDlgPathCompound.h | 2 -- src/Mod/Path/Gui/ViewProviderArea.cpp | 3 -- src/Mod/Path/Gui/ViewProviderArea.h | 2 -- src/Mod/Path/Gui/ViewProviderPath.cpp | 1 - src/Mod/Path/Gui/ViewProviderPath.h | 2 -- src/Mod/Path/Gui/ViewProviderPathCompound.cpp | 2 -- src/Mod/Path/Gui/ViewProviderPathCompound.h | 4 +-- src/Mod/Path/Gui/ViewProviderPathShape.cpp | 2 -- src/Mod/Path/Gui/ViewProviderPathShape.h | 4 +-- src/Mod/Path/PathSimulator/App/PreCompiled.h | 19 +++++++++++ 18 files changed, 65 insertions(+), 43 deletions(-) diff --git a/src/Mod/Path/App/Area.cpp b/src/Mod/Path/App/Area.cpp index e9e4700257..92494e4d48 100644 --- a/src/Mod/Path/App/Area.cpp +++ b/src/Mod/Path/App/Area.cpp @@ -45,8 +45,8 @@ # include # include # include -# include # include +# include # include # include # include diff --git a/src/Mod/Path/App/PreCompiled.h b/src/Mod/Path/App/PreCompiled.h index 11fc11b120..b510b2868c 100644 --- a/src/Mod/Path/App/PreCompiled.h +++ b/src/Mod/Path/App/PreCompiled.h @@ -20,6 +20,7 @@ * * ***************************************************************************/ + #ifndef PATH_PRECOMPILED_H #define PATH_PRECOMPILED_H @@ -43,19 +44,30 @@ #ifdef _PreComp_ // standard +#include +#include +#include #include +#include #include +#include #include +#include #include #include #include // Boost +#include #include +#include +#include +#include #include #include #include #include +#include #include //OCC @@ -65,23 +77,32 @@ #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 +#include #include #include #include @@ -94,6 +115,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Mod/Path/Gui/AppPathGuiPy.cpp b/src/Mod/Path/Gui/AppPathGuiPy.cpp index 63f6066b1f..5b336d208d 100644 --- a/src/Mod/Path/Gui/AppPathGuiPy.cpp +++ b/src/Mod/Path/Gui/AppPathGuiPy.cpp @@ -23,8 +23,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include - # include # include #endif diff --git a/src/Mod/Path/Gui/Command.cpp b/src/Mod/Path/Gui/Command.cpp index 2ee14b9d5e..0d817c5c74 100644 --- a/src/Mod/Path/Gui/Command.cpp +++ b/src/Mod/Path/Gui/Command.cpp @@ -22,7 +22,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include #endif diff --git a/src/Mod/Path/Gui/DlgProcessorChooser.cpp b/src/Mod/Path/Gui/DlgProcessorChooser.cpp index f316f53919..273af7465e 100644 --- a/src/Mod/Path/Gui/DlgProcessorChooser.cpp +++ b/src/Mod/Path/Gui/DlgProcessorChooser.cpp @@ -23,7 +23,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include #endif diff --git a/src/Mod/Path/Gui/DlgProcessorChooser.h b/src/Mod/Path/Gui/DlgProcessorChooser.h index 5a36c3cd82..2cb7ae3021 100644 --- a/src/Mod/Path/Gui/DlgProcessorChooser.h +++ b/src/Mod/Path/Gui/DlgProcessorChooser.h @@ -23,7 +23,6 @@ #ifndef PATH_DlgProcessorChooser_H #define PATH_DlgProcessorChooser_H -#include #include diff --git a/src/Mod/Path/Gui/PreCompiled.h b/src/Mod/Path/Gui/PreCompiled.h index f110cd084c..7a7399fb4b 100644 --- a/src/Mod/Path/Gui/PreCompiled.h +++ b/src/Mod/Path/Gui/PreCompiled.h @@ -46,16 +46,29 @@ #ifdef _PreComp_ +// boost +#include + +// standard +#include +#include +#include + // STL #include +#include +#include +#include +#include +#include +#include +#include +#include #ifdef FC_OS_WIN32 # include #endif -// boost -#include - // OCC #include @@ -65,17 +78,9 @@ #endif // all of Inventor -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef __InventorAll__ +# include +#endif #endif //_PreComp_ diff --git a/src/Mod/Path/Gui/TaskDlgPathCompound.cpp b/src/Mod/Path/Gui/TaskDlgPathCompound.cpp index 9f00d2ae93..a5ff799522 100644 --- a/src/Mod/Path/Gui/TaskDlgPathCompound.cpp +++ b/src/Mod/Path/Gui/TaskDlgPathCompound.cpp @@ -23,7 +23,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include #endif diff --git a/src/Mod/Path/Gui/TaskDlgPathCompound.h b/src/Mod/Path/Gui/TaskDlgPathCompound.h index dae78306a5..0473b112ae 100644 --- a/src/Mod/Path/Gui/TaskDlgPathCompound.h +++ b/src/Mod/Path/Gui/TaskDlgPathCompound.h @@ -23,8 +23,6 @@ #ifndef PATHGUI_TaskDlgPathCompound_H #define PATHGUI_TaskDlgPathCompound_H -#include - #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderArea.cpp b/src/Mod/Path/Gui/ViewProviderArea.cpp index 11768c59e0..8a2cca3282 100644 --- a/src/Mod/Path/Gui/ViewProviderArea.cpp +++ b/src/Mod/Path/Gui/ViewProviderArea.cpp @@ -21,9 +21,6 @@ ****************************************************************************/ #include "PreCompiled.h" -#ifndef _PreComp_ -# include -#endif #include #include diff --git a/src/Mod/Path/Gui/ViewProviderArea.h b/src/Mod/Path/Gui/ViewProviderArea.h index 5bde542864..7da299d4b5 100644 --- a/src/Mod/Path/Gui/ViewProviderArea.h +++ b/src/Mod/Path/Gui/ViewProviderArea.h @@ -23,8 +23,6 @@ #ifndef PATH_ViewProviderArea_H #define PATH_ViewProviderArea_H -#include - #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPath.cpp b/src/Mod/Path/Gui/ViewProviderPath.cpp index 3ca37dfbd5..63b24a4bae 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.cpp +++ b/src/Mod/Path/Gui/ViewProviderPath.cpp @@ -23,7 +23,6 @@ #include "PreCompiled.h" #ifndef _PreComp_ -# include # include # include diff --git a/src/Mod/Path/Gui/ViewProviderPath.h b/src/Mod/Path/Gui/ViewProviderPath.h index 7f39f6fc31..9b5b4c1762 100644 --- a/src/Mod/Path/Gui/ViewProviderPath.h +++ b/src/Mod/Path/Gui/ViewProviderPath.h @@ -23,8 +23,6 @@ #ifndef PATH_ViewProviderPath_H #define PATH_ViewProviderPath_H -#include - #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathCompound.cpp b/src/Mod/Path/Gui/ViewProviderPathCompound.cpp index facc075bf4..a6d72afa0e 100644 --- a/src/Mod/Path/Gui/ViewProviderPathCompound.cpp +++ b/src/Mod/Path/Gui/ViewProviderPathCompound.cpp @@ -22,8 +22,6 @@ #include "PreCompiled.h" -#include - #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathCompound.h b/src/Mod/Path/Gui/ViewProviderPathCompound.h index 0b14f229dd..0930cf8b8e 100644 --- a/src/Mod/Path/Gui/ViewProviderPathCompound.h +++ b/src/Mod/Path/Gui/ViewProviderPathCompound.h @@ -20,14 +20,12 @@ * * ***************************************************************************/ + #ifndef PATH_ViewProviderPathCompound_H #define PATH_ViewProviderPathCompound_H -#include - #include "ViewProviderPath.h" - namespace PathGui { diff --git a/src/Mod/Path/Gui/ViewProviderPathShape.cpp b/src/Mod/Path/Gui/ViewProviderPathShape.cpp index 6b735c6ea9..cb0b45cdf3 100644 --- a/src/Mod/Path/Gui/ViewProviderPathShape.cpp +++ b/src/Mod/Path/Gui/ViewProviderPathShape.cpp @@ -22,8 +22,6 @@ #include "PreCompiled.h" -#include - #include #include #include diff --git a/src/Mod/Path/Gui/ViewProviderPathShape.h b/src/Mod/Path/Gui/ViewProviderPathShape.h index 55a73ce9d8..8e60a3b7d8 100644 --- a/src/Mod/Path/Gui/ViewProviderPathShape.h +++ b/src/Mod/Path/Gui/ViewProviderPathShape.h @@ -20,14 +20,12 @@ * * ***************************************************************************/ + #ifndef PATH_ViewProviderPathShape_H #define PATH_ViewProviderPathShape_H -#include - #include "ViewProviderPath.h" - namespace PathGui { diff --git a/src/Mod/Path/PathSimulator/App/PreCompiled.h b/src/Mod/Path/PathSimulator/App/PreCompiled.h index a1dfa37453..c8463f6304 100644 --- a/src/Mod/Path/PathSimulator/App/PreCompiled.h +++ b/src/Mod/Path/PathSimulator/App/PreCompiled.h @@ -40,10 +40,29 @@ #ifdef _PreComp_ +// standard +#include +#include +#include + // STL #include +#include +#include +#include +#include +#include +#include +#include +#include #include +// Boost +#include + +// Xerces +#include + #endif //_PreComp_ #endif From e6b3d5aded0f73247b462d78329cc02193b653b7 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 20:27:26 +0100 Subject: [PATCH 04/26] [PD] improve PreCompiled.h handling --- src/Gui/QtAll.h | 5 ++- src/Mod/Part/App/OpenCascadeAll.h | 2 + src/Mod/PartDesign/App/PreCompiled.h | 65 +--------------------------- src/Mod/PartDesign/Gui/PreCompiled.h | 62 ++++++++------------------ 4 files changed, 23 insertions(+), 111 deletions(-) diff --git a/src/Gui/QtAll.h b/src/Gui/QtAll.h index b22fcfc1c2..f2ab5e6382 100644 --- a/src/Gui/QtAll.h +++ b/src/Gui/QtAll.h @@ -63,7 +63,7 @@ #include #include #include -#include +#include #include #include #include @@ -104,8 +104,9 @@ #include #include #include +#include #include -#include +#include #include #include #include diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index 0940603e49..d9f8caa56f 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -106,6 +106,7 @@ #endif #include +#include #if OCC_VERSION_HEX < 0x070300 # include #endif @@ -478,6 +479,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Mod/PartDesign/App/PreCompiled.h b/src/Mod/PartDesign/App/PreCompiled.h index 1417f4adf3..7f4ed7207f 100644 --- a/src/Mod/PartDesign/App/PreCompiled.h +++ b/src/Mod/PartDesign/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef __PRECOMPILED__ #define __PRECOMPILED__ @@ -35,71 +34,9 @@ #ifdef _PreComp_ -// standard -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -// QT -#include -#include - -// OpenCasCade ===================================================================================== +// OpenCasCade #include -// Apart from the Part OpenCascadeAll, I need: -# 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 -# include - -# include - -# include -# include -# include -# include - -# include - #endif // _PreComp_ #endif diff --git a/src/Mod/PartDesign/Gui/PreCompiled.h b/src/Mod/PartDesign/Gui/PreCompiled.h index bb26a57325..4065daab5c 100644 --- a/src/Mod/PartDesign/Gui/PreCompiled.h +++ b/src/Mod/PartDesign/Gui/PreCompiled.h @@ -20,71 +20,43 @@ * * ***************************************************************************/ - #ifndef __PRECOMPILED_GUI__ #define __PRECOMPILED_GUI__ #include - #ifdef _MSC_VER # pragma warning(disable : 4005) #endif #ifdef _PreComp_ -// standard -#include -#include -#include -#include -#include - -// Boost -#include -#include - -// OCC -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// STL -#include -#include -#include -#include -#include -#include -#include -#include -#include - #ifdef FC_OS_WIN32 # include #endif +// Boost +#include -// Qt Toolkit +// OCC +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Qt #ifndef __QtAll__ # include #endif -#include -#include -#include -#include - // Inventor #ifndef __InventorAll__ # include From 378184f8eab9f8ac8300d63e26dd9b7b67b69272 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 23:19:38 +0100 Subject: [PATCH 05/26] [Points] re-add a header --- src/Mod/Points/App/PointsAlgos.cpp | 1 + src/Mod/Points/App/PreCompiled.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Mod/Points/App/PointsAlgos.cpp b/src/Mod/Points/App/PointsAlgos.cpp index 13889cc27a..5ca0dc6a96 100644 --- a/src/Mod/Points/App/PointsAlgos.cpp +++ b/src/Mod/Points/App/PointsAlgos.cpp @@ -31,6 +31,7 @@ # include # include # include +# include // needed for compilation on some systems #endif #include diff --git a/src/Mod/Points/App/PreCompiled.h b/src/Mod/Points/App/PreCompiled.h index 423f04153f..9e42e5ad7a 100644 --- a/src/Mod/Points/App/PreCompiled.h +++ b/src/Mod/Points/App/PreCompiled.h @@ -48,9 +48,9 @@ // boost # include -# include # include # include +# include // Qt # include From 6e5be5232552ffced62017679d42a9f18dd9ab41 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 22:40:56 +0100 Subject: [PATCH 06/26] [Part] improve PreCompiled.h handling --- .../Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp | 3 +- .../App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp | 3 +- src/Mod/Part/App/OpenCascadeAll.h | 3 + src/Mod/Part/App/PreCompiled.h | 59 +++---- src/Mod/Part/App/TopoShape.cpp | 5 +- src/Mod/Part/Gui/PreCompiled.h | 152 +++--------------- src/Mod/Part/Gui/ReferenceHighlighter.cpp | 9 +- src/Mod/Part/Gui/ViewProviderExt.cpp | 6 +- 8 files changed, 60 insertions(+), 180 deletions(-) diff --git a/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp index 8337afd4b2..1a176548a9 100644 --- a/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp +++ b/src/Mod/Part/App/HLRBRep/HLRBRep_AlgoPyImp.cpp @@ -27,11 +27,12 @@ # include # include # include + +# include #endif #include #include -#include #include "HLRBRep/HLRBRep_AlgoPy.h" #include "HLRBRep/HLRBRep_AlgoPy.cpp" diff --git a/src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp b/src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp index e5c296dd7e..99b780d9dd 100644 --- a/src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp +++ b/src/Mod/Part/App/HLRBRep/HLRBRep_PolyAlgoPyImp.cpp @@ -28,11 +28,12 @@ # include # include # include + +# include #endif #include #include -#include #include "HLRBRep/HLRBRep_PolyAlgoPy.h" #include "HLRBRep/HLRBRep_PolyAlgoPy.cpp" diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index d9f8caa56f..475b1704ee 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -377,6 +377,8 @@ #include #include #include +#include +#include #include #include #include @@ -413,6 +415,7 @@ #include #include #include +#include #include #include diff --git a/src/Mod/Part/App/PreCompiled.h b/src/Mod/Part/App/PreCompiled.h index 0cf36e4f2e..804a3216a1 100644 --- a/src/Mod/Part/App/PreCompiled.h +++ b/src/Mod/Part/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef PART_PRECOMPILED_H #define PART_PRECOMPILED_H @@ -36,69 +35,53 @@ # pragma warning( disable : 4786 ) // specifier longer then 255 chars #endif - #ifdef _PreComp_ // standard -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include - #include #include #include #include #include -// QT +// STL +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// Qt #include // Boost -#include -#include - -#include -#include - -#include -//namespace po = boost::program_options; - -#include -#include -#include - #include +#include +#include +#include +#include #include +// OpenCasCade #include "OpenCascadeAll.h" -#include -#include #elif defined(FC_OS_WIN32) #define WIN32_LEAN_AND_MEAN #ifndef NOMINMAX -#define NOMINMAX +# define NOMINMAX #endif #include #include #endif //_PreComp_ #ifndef _Standard_Version_HeaderFile -#include +# include #endif - #endif diff --git a/src/Mod/Part/App/TopoShape.cpp b/src/Mod/Part/App/TopoShape.cpp index f538576ff6..db2892d768 100644 --- a/src/Mod/Part/App/TopoShape.cpp +++ b/src/Mod/Part/App/TopoShape.cpp @@ -160,11 +160,10 @@ # include #endif +# include +# include #endif // _PreComp_ -#include -#include - #include #include #include diff --git a/src/Mod/Part/Gui/PreCompiled.h b/src/Mod/Part/Gui/PreCompiled.h index e5529a024d..f88b6d206d 100644 --- a/src/Mod/Part/Gui/PreCompiled.h +++ b/src/Mod/Part/Gui/PreCompiled.h @@ -45,118 +45,22 @@ #ifdef _PreComp_ // standard -#include -#include #include -# include -#include +#include // STL -#include -#include -#include -#include -#include #include -#include -#include -#include +#include +#include +#include +#include -// OpenCasCade Base -#include -#include - -#if OCC_VERSION_HEX < 0x070400 -#include -#endif -#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 -#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 -#include -#include -#include -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include - -# include -# include +// OpenCasCade +#include // Boost -#include -#include +#include +#include // Qt Toolkit #ifndef __QtAll__ @@ -165,33 +69,23 @@ // GL // Include glext before InventorAll -# ifdef FC_OS_WIN32 +#ifdef FC_OS_WIN32 +# include +# include +#else +# ifdef FC_OS_MACOSX +# include +# include +# else +# ifndef GL_GLEXT_PROTOTYPES +# define GL_GLEXT_PROTOTYPES 1 +# endif # include # include -# else -# ifdef FC_OS_MACOSX -# include -# include -# else -# ifndef GL_GLEXT_PROTOTYPES -# define GL_GLEXT_PROTOTYPES 1 -# endif -# include -# include -# endif //FC_OS_MACOSX -# endif //FC_OS_WIN32 +# endif //FC_OS_MACOSX +#endif //FC_OS_WIN32 // Should come after glext.h to avoid warnings -# include - -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include // Inventor includes OpenGL #ifndef __InventorAll__ diff --git a/src/Mod/Part/Gui/ReferenceHighlighter.cpp b/src/Mod/Part/Gui/ReferenceHighlighter.cpp index 480a57db64..a42d50bc7e 100644 --- a/src/Mod/Part/Gui/ReferenceHighlighter.cpp +++ b/src/Mod/Part/Gui/ReferenceHighlighter.cpp @@ -20,15 +20,14 @@ * * ***************************************************************************/ - #include "PreCompiled.h" - #ifndef _PreComp_ -#include -#include +# include +# include + +# include #endif -#include #include "ReferenceHighlighter.h" diff --git a/src/Mod/Part/Gui/ViewProviderExt.cpp b/src/Mod/Part/Gui/ViewProviderExt.cpp index 4b1761d6e7..3eff9506e2 100644 --- a/src/Mod/Part/Gui/ViewProviderExt.cpp +++ b/src/Mod/Part/Gui/ViewProviderExt.cpp @@ -66,10 +66,10 @@ # include # include # include -#endif -#include -#include +# include +# include +#endif #include #include From b8c83a1c6225a3836e2267365c58d37d59c608e9 Mon Sep 17 00:00:00 2001 From: wmayer Date: Wed, 7 Dec 2022 23:31:20 +0100 Subject: [PATCH 07/26] PD: refactor CmdPartDesignNewSketch::activated --- src/Mod/PartDesign/Gui/CMakeLists.txt | 2 + src/Mod/PartDesign/Gui/Command.cpp | 337 +--------- src/Mod/PartDesign/Gui/SketchWorkflow.cpp | 729 ++++++++++++++++++++++ src/Mod/PartDesign/Gui/SketchWorkflow.h | 65 ++ 4 files changed, 799 insertions(+), 334 deletions(-) create mode 100644 src/Mod/PartDesign/Gui/SketchWorkflow.cpp create mode 100644 src/Mod/PartDesign/Gui/SketchWorkflow.h diff --git a/src/Mod/PartDesign/Gui/CMakeLists.txt b/src/Mod/PartDesign/Gui/CMakeLists.txt index 105f1d821d..376f557dee 100644 --- a/src/Mod/PartDesign/Gui/CMakeLists.txt +++ b/src/Mod/PartDesign/Gui/CMakeLists.txt @@ -218,6 +218,8 @@ SET(PartDesignGuiModule_SRCS Resources/PartDesign.qrc PreCompiled.cpp PreCompiled.h + SketchWorkflow.cpp + SketchWorkflow.h Utils.cpp Utils.h Workbench.cpp diff --git a/src/Mod/PartDesign/Gui/Command.cpp b/src/Mod/PartDesign/Gui/Command.cpp index befdd97a53..7fae3e3eb5 100644 --- a/src/Mod/PartDesign/Gui/Command.cpp +++ b/src/Mod/PartDesign/Gui/Command.cpp @@ -59,6 +59,7 @@ #include "DlgActiveBody.h" #include "ReferenceSelection.h" +#include "SketchWorkflow.h" #include "TaskFeaturePick.h" #include "Utils.h" #include "WorkflowManager.h" @@ -494,340 +495,8 @@ CmdPartDesignNewSketch::CmdPartDesignNewSketch() void CmdPartDesignNewSketch::activated(int iMsg) { Q_UNUSED(iMsg); - App::Document *doc = getDocument (); - PartDesign::Body *pcActiveBody( nullptr ); - auto shouldMakeBody( false ); - - if ( PartDesignGui::assureModernWorkflow( doc ) ) { - // We need either an active Body, or for there to be no Body - // objects (in which case, just make one) to make a new sketch. - - pcActiveBody = PartDesignGui::getBody( /* messageIfNot = */ false ); - if (!pcActiveBody) { - if ( doc->countObjectsOfType(PartDesign::Body::getClassTypeId()) == 0 ) { - shouldMakeBody = true; - } else { - PartDesignGui::DlgActiveBody dia(Gui::getMainWindow(), doc); - if (dia.exec() == QDialog::DialogCode::Accepted) - pcActiveBody = dia.getActiveBody(); - if (!pcActiveBody) - return; - } - } - - } else { - // No PartDesign feature without Body past FreeCAD 0.13 - if ( PartDesignGui::isLegacyWorkflow( doc ) ) { - Gui::CommandManager &rcCmdMgr = Gui::Application::Instance->commandManager(); - rcCmdMgr.runCommandByName("Sketcher_NewSketch"); - } - return; - } - - // Hint: - // The behaviour of this command has changed with respect to a selected sketch: - // It doesn't try any more to edit a selected sketch but always tries to create - // a new sketch. - // See https://forum.freecadweb.org/viewtopic.php?f=3&t=44070 - - Gui::SelectionFilter FaceFilter ("SELECT Part::Feature SUBELEMENT Face COUNT 1"); - Gui::SelectionFilter PlaneFilter ("SELECT App::Plane COUNT 1"); - Gui::SelectionFilter PlaneFilter2("SELECT PartDesign::Plane COUNT 1"); - - if (PlaneFilter2.match()) - PlaneFilter = PlaneFilter2; - - if ( FaceFilter.match() || PlaneFilter.match() ) { - if (!pcActiveBody) { - // We shouldn't make a new Body in this case, because that means - // the source shape of the face/plane would be outside the Body. - PartDesignGui::getBody( /* messageIfNot = */ true ); - return; - } - - // get the selected object - std::string supportString; - App::DocumentObject* obj; - - if (FaceFilter.match()) { - Gui::SelectionObject faceSelObject = FaceFilter.Result[0][0]; - const std::vector& subNames = faceSelObject.getSubNames(); - obj = faceSelObject.getObject(); - - if (!obj->isDerivedFrom(Part::Feature::getClassTypeId())) - return; - - // In case the selected face belongs to the body then it means its - // Display Mode Body is set to Tip. But the body face is not allowed - // to be used as support because otherwise it would cause a cyclic - // dependency. So, instead we use the tip object as reference. - // https://forum.freecadweb.org/viewtopic.php?f=3&t=37448 - if (obj == pcActiveBody) { - App::DocumentObject* tip = pcActiveBody->Tip.getValue(); - if (tip && tip->isDerivedFrom(Part::Feature::getClassTypeId()) && subNames.size() == 1) { - Gui::SelectionChanges msg; - msg.pDocName = faceSelObject.getDocName(); - msg.pObjectName = tip->getNameInDocument(); - msg.pSubName = subNames[0].c_str(); - msg.pTypeName = tip->getTypeId().getName(); - - faceSelObject = Gui::SelectionObject(msg); - obj = tip; - - // automatically switch to 'Through' mode - PartDesignGui::ViewProviderBody* vpBody = dynamic_cast - (Gui::Application::Instance->getViewProvider(pcActiveBody)); - if (vpBody) { - vpBody->DisplayModeBody.setValue("Through"); - } - } - } - - Part::Feature* feat = static_cast(obj); - - if (subNames.size() > 1) { - // No assert for wrong user input! - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Several sub-elements selected"), - QObject::tr("You have to select a single face as support for a sketch!")); - return; - } - - // get the selected sub shape (a Face) - const Part::TopoShape &shape = feat->Shape.getValue(); - TopoDS_Shape sh = shape.getSubShape(subNames[0].c_str()); - const TopoDS_Face& face = TopoDS::Face(sh); - if (face.IsNull()) { - // No assert for wrong user input! - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No support face selected"), - QObject::tr("You have to select a face as support for a sketch!")); - return; - } - - BRepAdaptor_Surface adapt(face); - if (adapt.GetType() != GeomAbs_Plane) { - TopLoc_Location loc; - Handle(Geom_Surface) surf = BRep_Tool::Surface(face, loc); - if (surf.IsNull() || !GeomLib_IsPlanarSurface(surf).IsPlanar()) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No planar support"), - QObject::tr("You need a planar face as support for a sketch!")); - return; - } - } - - supportString = faceSelObject.getAsPropertyLinkSubString(); - } - else { - obj = PlaneFilter.Result[0][0].getObject(); - supportString = getObjectCmd(obj,"(",",'')"); - } - - - if (!pcActiveBody->hasObject(obj)) { - if ( !obj->isDerivedFrom ( App::Plane::getClassTypeId() ) ) { - // TODO check here if the plane associated with right part/body (2015-09-01, Fat-Zer) - - auto pcActivePart = PartDesignGui::getPartFor(pcActiveBody, false); - - //check the prerequisites for the selected objects - //the user has to decide which option we should take if external references are used - // TODO share this with UnifiedDatumCommand() (2015-10-20, Fat-Zer) - QDialog dia(Gui::getMainWindow()); - PartDesignGui::Ui_DlgReference dlg; - dlg.setupUi(&dia); - dia.setModal(true); - int result = dia.exec(); - if (result == QDialog::DialogCode::Rejected) - return; - else if (!dlg.radioXRef->isChecked()) { - openCommand(QT_TRANSLATE_NOOP("Command", "Make copy")); - std::string sub; - if (FaceFilter.match()) - sub = FaceFilter.Result[0][0].getSubNames()[0]; - auto copy = PartDesignGui::TaskFeaturePick::makeCopy(obj, sub, dlg.radioIndependent->isChecked()); - - if (pcActiveBody) - pcActiveBody->addObject(copy); - else if (pcActivePart) - pcActivePart->addObject(copy); - - if (PlaneFilter.match()) - supportString = getObjectCmd(copy,"(",",'')"); - else - //it is ensured that only a single face is selected, hence it must always be Face1 of the shapebinder - supportString = getObjectCmd(copy,"(",",'Face1')"); - commitCommand(); - } - } - } - - // create Sketch on Face or Plane - std::string FeatName = getUniqueObjectName("Sketch",pcActiveBody); - - openCommand(QT_TRANSLATE_NOOP("Command", "Create a Sketch on Face")); - FCMD_OBJ_CMD(pcActiveBody,"newObject('Sketcher::SketchObject','" << FeatName << "')"); - auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str()); - FCMD_OBJ_CMD(Feat,"Support = " << supportString); - FCMD_OBJ_CMD(Feat,"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'"); - updateActive(); - PartDesignGui::setEdit(Feat,pcActiveBody); - } - else { - App::GeoFeatureGroupExtension *geoGroup( nullptr ); - if (pcActiveBody) { - auto group( App::GeoFeatureGroupExtension::getGroupOfObject(pcActiveBody) ); - if (group) { - geoGroup = group->getExtensionByType(); - } - } - - std::vector planes; - std::vector status; - - // Start command early, so undo will undo any Body creation - Gui::Command::openCommand(QT_TRANSLATE_NOOP("Command", "Create a new Sketch")); - if (shouldMakeBody) { - pcActiveBody = PartDesignGui::makeBody(doc); - if ( !pcActiveBody ) { - Base::Console().Error("Failed to create a Body object"); - return; - } - } - - // At this point, we have pcActiveBody - - unsigned validPlaneCount = 0; - - // Baseplanes are preapproved - try { - for ( auto plane: pcActiveBody->getOrigin ()->planes() ) { - planes.push_back (plane); - status.push_back(PartDesignGui::TaskFeaturePick::basePlane); - validPlaneCount++; - } - } catch (const Base::Exception &ex) { - Base::Console().Error ("%s\n", ex.what() ); - } - - auto datumPlanes( getDocument()->getObjectsOfType(PartDesign::Plane::getClassTypeId()) ); - for (auto plane: datumPlanes) { - planes.push_back ( plane ); - // Check whether this plane belongs to the active body - if ( pcActiveBody->hasObject(plane) ) { - if ( !pcActiveBody->isAfterInsertPoint ( plane ) ) { - validPlaneCount++; - status.push_back(PartDesignGui::TaskFeaturePick::validFeature); - } else { - status.push_back(PartDesignGui::TaskFeaturePick::afterTip); - } - } else { - PartDesign::Body *planeBody = PartDesign::Body::findBodyOf (plane); - if ( planeBody ) { - if ( ( geoGroup && geoGroup->hasObject ( planeBody, true ) ) || - !App::GeoFeatureGroupExtension::getGroupOfObject (planeBody) ) { - status.push_back ( PartDesignGui::TaskFeaturePick::otherBody ); - } else { - status.push_back ( PartDesignGui::TaskFeaturePick::otherPart ); - } - } else { - if ( ( geoGroup && geoGroup->hasObject ( plane, true ) ) || - !App::GeoFeatureGroupExtension::getGroupOfObject ( plane ) ) { - status.push_back ( PartDesignGui::TaskFeaturePick::otherPart ); - } else { - status.push_back ( PartDesignGui::TaskFeaturePick::notInBody ); - } - } - } - } - - // Collect also shape binders consisting of a single planar face - auto shapeBinders( getDocument()->getObjectsOfType(PartDesign::ShapeBinder::getClassTypeId()) ); - auto binders( getDocument()->getObjectsOfType(PartDesign::SubShapeBinder::getClassTypeId()) ); - shapeBinders.insert(shapeBinders.end(),binders.begin(),binders.end()); - for (auto binder : shapeBinders) { - // Check whether this plane belongs to the active body - if (pcActiveBody->hasObject(binder)) { - TopoDS_Shape shape = static_cast(binder)->Shape.getValue(); - if (!shape.IsNull() && shape.ShapeType() == TopAbs_FACE) { - const TopoDS_Face& face = TopoDS::Face(shape); - TopLoc_Location loc; - Handle(Geom_Surface) surf = BRep_Tool::Surface(face, loc); - if (!surf.IsNull() && GeomLib_IsPlanarSurface(surf).IsPlanar()) { - if (!pcActiveBody->isAfterInsertPoint (binder)) { - validPlaneCount++; - planes.push_back(binder); - status.push_back(PartDesignGui::TaskFeaturePick::validFeature); - } - } - } - } - } - - // Determines if user made a valid selection in dialog - auto accepter = [](const std::vector& features) -> bool { - return !features.empty(); - }; - - // Called by dialog when user hits "OK" and accepter returns true - auto worker = [=](const std::vector& features) { - // may happen when the user switched to an empty document while the - // dialog is open - if (features.empty()) - return; - App::Plane* plane = static_cast(features.front()); - std::string FeatName = getUniqueObjectName("Sketch",pcActiveBody); - std::string supportString = getObjectCmd(plane,"(",",[''])"); - - FCMD_OBJ_CMD(pcActiveBody,"newObject('Sketcher::SketchObject','" << FeatName << "')"); - auto Feat = pcActiveBody->getDocument()->getObject(FeatName.c_str()); - FCMD_OBJ_CMD(Feat,"Support = " << supportString); - FCMD_OBJ_CMD(Feat,"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'"); - Gui::Command::updateActive(); // Make sure the Support's Placement property is updated - PartDesignGui::setEdit(Feat,pcActiveBody); - }; - - // Called by dialog for "Cancel", or "OK" if accepter returns false - std::string docname = doc->getName(); - auto quitter = [docname]() { - Gui::Document* document = Gui::Application::Instance->getDocument(docname.c_str()); - if (document) - document->abortCommand(); - }; - - if (validPlaneCount == 0) { - QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid planes in this document"), - QObject::tr("Please create a plane first or select a face to sketch on")); - quitter(); - return; - - } else if (validPlaneCount == 1) { - worker(planes); - - } else if (validPlaneCount > 1) { - // Show dialog and let user pick plane - Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); - PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast(dlg); - if (dlg && !pickDlg) { - QMessageBox msgBox; - msgBox.setText(QObject::tr("A dialog is already open in the task panel")); - msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); - msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); - msgBox.setDefaultButton(QMessageBox::Yes); - int ret = msgBox.exec(); - if (ret == QMessageBox::Yes) - Gui::Control().closeDialog(); - else { - quitter(); - return; - } - } - - if (dlg) - Gui::Control().closeDialog(); - - Gui::Selection().clearSelection(); - Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, accepter, worker, true, quitter)); - } - } + PartDesignGui::SketchWorkflow creator(getActiveGuiDocument()); + creator.createSketch(); } bool CmdPartDesignNewSketch::isActive() diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp new file mode 100644 index 0000000000..6b56e7af7c --- /dev/null +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp @@ -0,0 +1,729 @@ +/************************************************************************** +* Copyright (c) 2022 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 +# include +# include +# include +# include +# include +# include +#endif + +#include "SketchWorkflow.h" +#include "DlgActiveBody.h" +#include "TaskFeaturePick.h" +#include "Utils.h" +#include "ViewProviderBody.h" +#include "WorkflowManager.h" +#include "ui_DlgReference.h" +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace PartDesignGui; + +namespace { +struct RejectException +{ + +}; + +struct WrongSelectionException +{ + +}; + +struct WrongSupportException +{ + +}; + +struct SupportNotPlanarException +{ + +}; + +struct MissingPlanesException +{ + +}; + +class SupportFaceValidator +{ +public: + SupportFaceValidator(Gui::SelectionObject faceSelection) + : faceSelection(faceSelection) + { + } + + void handleSelectedBody(PartDesign::Body* activeBody) + { + App::DocumentObject* object = faceSelection.getObject(); + std::vector elements = faceSelection.getSubNames(); + + // In case the selected face belongs to the body then it means its + // Display Mode Body is set to Tip. But the body face is not allowed + // to be used as support because otherwise it would cause a cyclic + // dependency. So, instead we use the tip object as reference. + // https://forum.freecadweb.org/viewtopic.php?f=3&t=37448 + if (object == activeBody) { + App::DocumentObject* tip = activeBody->Tip.getValue(); + if (tip && tip->isDerivedFrom(Part::Feature::getClassTypeId()) && elements.size() == 1) { + Gui::SelectionChanges msg; + msg.pDocName = faceSelection.getDocName(); + msg.pObjectName = tip->getNameInDocument(); + msg.pSubName = elements[0].c_str(); + msg.pTypeName = tip->getTypeId().getName(); + + faceSelection = Gui::SelectionObject{msg}; + + // automatically switch to 'Through' mode + setThroughModeOfBody(activeBody); + } + } + } + + void throwIfInvalid() + { + App::DocumentObject* object = faceSelection.getObject(); + std::vector elements = faceSelection.getSubNames(); + + Part::Feature* partobject = dynamic_cast(object); + if (!partobject) { + throw WrongSelectionException(); + } + + if (elements.size() != 1) { + throw WrongSelectionException(); + } + + // get the selected sub shape (a Face) + const Part::TopoShape &shape = partobject->Shape.getValue(); + Part::TopoShape subshape(shape.getSubShape(elements[0].c_str())); + if (subshape.isNull()) { + throw WrongSupportException(); + } + + if (!subshape.isPlanar()) { + throw SupportNotPlanarException(); + } + } + + std::string getSupport() const + { + return faceSelection.getAsPropertyLinkSubString(); + } + + App::DocumentObject* getObject() const + { + return faceSelection.getObject(); + } + +private: + void setThroughModeOfBody(PartDesign::Body* activeBody) + { + // automatically switch to 'Through' mode + PartDesignGui::ViewProviderBody* vpBody = dynamic_cast + (Gui::Application::Instance->getViewProvider(activeBody)); + if (vpBody) { + vpBody->DisplayModeBody.setValue("Through"); + } + } + +private: + mutable Gui::SelectionObject faceSelection; +}; + +class SupportPlaneValidator +{ +public: + SupportPlaneValidator(Gui::SelectionObject faceSelection) + : faceSelection(faceSelection) + { + } + + std::string getSupport() const + { + return Gui::Command::getObjectCmd(getObject(), "(",",'')"); + } + + App::DocumentObject* getObject() const + { + return faceSelection.getObject(); + } + +private: + mutable Gui::SelectionObject faceSelection; +}; + +class SketchPreselection +{ +public: + SketchPreselection(Gui::Document* guidocument, PartDesign::Body* activeBody, + std::tuple filter) + : guidocument(guidocument) + , activeBody(activeBody) + , faceFilter(std::get<0>(filter)) + , planeFilter(std::get<1>(filter)) + { + } + + bool matches() + { + return faceFilter.match() || planeFilter.match(); + } + + std::string getSupport() const + { + return supportString; + } + + void createSupport() + { + createBodyOrThrow(); + + // get the selected object + App::DocumentObject* selectedObject{}; + + if (faceFilter.match()) { + Gui::SelectionObject faceSelObject = faceFilter.Result[0][0]; + SupportFaceValidator validator{faceSelObject}; + validator.handleSelectedBody(activeBody); + validator.throwIfInvalid(); + + selectedObject = validator.getObject(); + supportString = validator.getSupport(); + } + else { + SupportPlaneValidator validator(planeFilter.Result[0][0]); + selectedObject = validator.getObject(); + supportString = validator.getSupport(); + } + + handleIfSupportOutOfBody(selectedObject); + } + + void createSketchOnSupport(const std::string& supportString) + { + // create Sketch on Face or Plane + App::Document* appdocument = guidocument->getDocument(); + std::string FeatName = appdocument->getUniqueObjectName("Sketch"); + + guidocument->openCommand(QT_TRANSLATE_NOOP("Command", "Create a Sketch on Face")); + FCMD_OBJ_CMD(activeBody, "newObject('Sketcher::SketchObject','" << FeatName << "')"); + auto Feat = appdocument->getObject(FeatName.c_str()); + FCMD_OBJ_CMD(Feat, "Support = " << supportString); + FCMD_OBJ_CMD(Feat, "MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'"); + Gui::Command::updateActive(); + PartDesignGui::setEdit(Feat, activeBody); + } + +private: + void createBodyOrThrow() + { + if (!activeBody) { + activeBody = PartDesignGui::getBody( /* messageIfNot = */ true ); + if (!activeBody) { + throw RejectException(); + } + } + } + + void handleIfSupportOutOfBody(App::DocumentObject* selectedObject) + { + if (!activeBody->hasObject(selectedObject)) { + if ( !selectedObject->isDerivedFrom ( App::Plane::getClassTypeId() ) ) { + // TODO check here if the plane associated with right part/body (2015-09-01, Fat-Zer) + + //check the prerequisites for the selected objects + //the user has to decide which option we should take if external references are used + // TODO share this with UnifiedDatumCommand() (2015-10-20, Fat-Zer) + QDialog dia(Gui::getMainWindow()); + PartDesignGui::Ui_DlgReference dlg; + dlg.setupUi(&dia); + dia.setModal(true); + int result = dia.exec(); + if (result == QDialog::Rejected) { + throw RejectException(); + } + + if (!dlg.radioXRef->isChecked()) { + guidocument->openCommand(QT_TRANSLATE_NOOP("Command", "Make copy")); + auto copy = makeCopy(selectedObject, dlg.radioIndependent->isChecked()); + supportString = supportFromCopy(copy); + guidocument->commitCommand(); + } + } + } + } + + App::DocumentObject* makeCopy(App::DocumentObject* selectedObject, bool independent) + { + std::string sub; + if (faceFilter.match()) + sub = faceFilter.Result[0][0].getSubNames()[0]; + auto copy = PartDesignGui::TaskFeaturePick::makeCopy(selectedObject, sub, independent); + + addToBodyOrPart(copy); + + return copy; + } + + std::string supportFromCopy(App::DocumentObject* copy) + { + std::string supportString; + if (planeFilter.match()) { + supportString = Gui::Command::getObjectCmd(copy,"(",",'')"); + } + else { + //it is ensured that only a single face is selected, hence it must always be Face1 of the shapebinder + supportString = Gui::Command::getObjectCmd(copy,"(",",'Face1')"); + } + return supportString; + } + + void addToBodyOrPart(App::DocumentObject* object) + { + auto activePart = PartDesignGui::getPartFor(activeBody, false); + if (activeBody) { + activeBody->addObject(object); + } + else if (activePart) { + activePart->addObject(object); + } + } + +private: + Gui::Document* guidocument; + PartDesign::Body* activeBody; + Gui::SelectionFilter faceFilter; + Gui::SelectionFilter planeFilter; + std::string supportString; +}; + +class PlaneFinder +{ +public: + PlaneFinder(App::Document* appdocument, PartDesign::Body* activeBody) + : appdocument(appdocument) + , activeBody(activeBody) + { + + } + + std::vector getPlanes() const + { + return planes; + } + + std::vector getStatus() const + { + return status; + } + + unsigned countValidPlanes() const + { + return validPlaneCount; + } + + void findBasePlanes() + { + try { + tryFindBasePlanes(); + } + catch (const Base::Exception &ex) { + Base::Console().Error ("%s\n", ex.what() ); + } + } + + void findDatumPlanes() + { + App::GeoFeatureGroupExtension *geoGroup = getGroupExtensionOfBody(); + auto datumPlanes( appdocument->getObjectsOfType(PartDesign::Plane::getClassTypeId()) ); + for (auto plane: datumPlanes) { + planes.push_back ( plane ); + // Check whether this plane belongs to the active body + if ( activeBody->hasObject(plane) ) { + if ( !activeBody->isAfterInsertPoint ( plane ) ) { + validPlaneCount++; + status.push_back(PartDesignGui::TaskFeaturePick::validFeature); + } else { + status.push_back(PartDesignGui::TaskFeaturePick::afterTip); + } + } else { + PartDesign::Body *planeBody = PartDesign::Body::findBodyOf (plane); + if ( planeBody ) { + if ( ( geoGroup && geoGroup->hasObject ( planeBody, true ) ) || + !App::GeoFeatureGroupExtension::getGroupOfObject (planeBody) ) { + status.push_back ( PartDesignGui::TaskFeaturePick::otherBody ); + } else { + status.push_back ( PartDesignGui::TaskFeaturePick::otherPart ); + } + } else { + if ( ( geoGroup && geoGroup->hasObject ( plane, true ) ) || + !App::GeoFeatureGroupExtension::getGroupOfObject ( plane ) ) { + status.push_back ( PartDesignGui::TaskFeaturePick::otherPart ); + } else { + status.push_back ( PartDesignGui::TaskFeaturePick::notInBody ); + } + } + } + } + } + + void findShapeBinderPlanes() + { + + // Collect also shape binders consisting of a single planar face + auto shapeBinders( appdocument->getObjectsOfType(PartDesign::ShapeBinder::getClassTypeId()) ); + auto binders( appdocument->getObjectsOfType(PartDesign::SubShapeBinder::getClassTypeId()) ); + shapeBinders.insert(shapeBinders.end(),binders.begin(),binders.end()); + for (auto binder : shapeBinders) { + // Check whether this plane belongs to the active body + if (activeBody->hasObject(binder)) { + Part::TopoShape shape = static_cast(binder)->Shape.getShape(); + if (shape.isPlanar()) { + if (!activeBody->isAfterInsertPoint (binder)) { + validPlaneCount++; + planes.push_back(binder); + status.push_back(PartDesignGui::TaskFeaturePick::validFeature); + } + } + } + } + } + +private: + void tryFindBasePlanes() + { + auto* origin = activeBody->getOrigin(); + for (auto plane : origin->planes()) { + planes.push_back (plane); + status.push_back(PartDesignGui::TaskFeaturePick::basePlane); + validPlaneCount++; + } + } + + App::GeoFeatureGroupExtension* getGroupExtensionOfBody() const + { + App::GeoFeatureGroupExtension *geoGroup{nullptr}; + if (activeBody) { + auto group( App::GeoFeatureGroupExtension::getGroupOfObject(activeBody) ); + if (group) { + geoGroup = group->getExtensionByType(); + } + } + + return geoGroup; + } + +private: + App::Document* appdocument; + PartDesign::Body* activeBody; + unsigned validPlaneCount = 0; + std::vector planes; + std::vector status; +}; + +class SketchRequestSelection +{ +public: + SketchRequestSelection(Gui::Document* guidocument, PartDesign::Body* activeBody) + : guidocument(guidocument) + , activeBody(activeBody) + { + } + + void findSupport() + { + try { + // Start command early, so undo will undo any Body creation + guidocument->openCommand(QT_TRANSLATE_NOOP("Command", "Create a new Sketch")); + tryFindSupport(); + } + catch (const RejectException&) { + guidocument->abortCommand(); + throw; + } + catch (const MissingPlanesException&) { + guidocument->abortCommand(); + throw; + } + } + +private: + void tryFindSupport() + { + createBodyOrThrow(); + findAndSelectPlane(); + } + + void createBodyOrThrow() + { + if (!activeBody) { + App::Document* appdocument = guidocument->getDocument(); + activeBody = PartDesignGui::makeBody(appdocument); + if (!activeBody) { + throw RejectException(); + } + } + } + + void findAndSelectPlane() + { + App::Document* appdocument = guidocument->getDocument(); + PlaneFinder planeFinder{appdocument, activeBody}; + planeFinder.findBasePlanes(); + planeFinder.findDatumPlanes(); + planeFinder.findShapeBinderPlanes(); + + std::vector planes = planeFinder.getPlanes(); + std::vector status = planeFinder.getStatus(); + unsigned validPlaneCount = planeFinder.countValidPlanes(); + + // + // Lambda definitions + // + App::Document* documentOfBody = appdocument; + PartDesign::Body* partDesignBody = activeBody; + + // Determines if user made a valid selection in dialog + auto acceptFunction = [](const std::vector& features) -> bool { + return !features.empty(); + }; + + // Called by dialog when user hits "OK" and accepter returns true + auto processFunction = [documentOfBody, partDesignBody](const std::vector& features) { + SketchRequestSelection::createSketch(documentOfBody, partDesignBody, features); + }; + + // Called by dialog for "Cancel", or "OK" if accepter returns false + std::string docname = documentOfBody->getName(); + auto rejectFunction = [docname]() { + Gui::Document* document = Gui::Application::Instance->getDocument(docname.c_str()); + if (document) + document->abortCommand(); + }; + + // + // End of lambda definitions + // + + if (validPlaneCount == 0) { + throw MissingPlanesException(); + } + else if (validPlaneCount == 1) { + processFunction(planes); + } + else if (validPlaneCount > 1) { + checkForShownDialog(); + Gui::Selection().clearSelection(); + + // Show dialog and let user pick plane + Gui::Control().showDialog(new PartDesignGui::TaskDlgFeaturePick(planes, status, acceptFunction, + processFunction, true, rejectFunction)); + } + } + + void checkForShownDialog() + { + Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog(); + PartDesignGui::TaskDlgFeaturePick *pickDlg = qobject_cast(dlg); + if (dlg && !pickDlg) { + QMessageBox msgBox; + msgBox.setText(QObject::tr("A dialog is already open in the task panel")); + msgBox.setInformativeText(QObject::tr("Do you want to close this dialog?")); + msgBox.setStandardButtons(QMessageBox::Yes | QMessageBox::No); + msgBox.setDefaultButton(QMessageBox::Yes); + int ret = msgBox.exec(); + if (ret == QMessageBox::Yes) { + Gui::Control().closeDialog(); + } + else { + throw RejectException(); + } + } + + if (dlg) { + Gui::Control().closeDialog(); + } + } + + static void createSketch(App::Document* documentOfBody, PartDesign::Body* partDesignBody, + const std::vector& features) + { + // may happen when the user switched to an empty document while the + // dialog is open + if (features.empty()) + return; + App::Plane* plane = static_cast(features.front()); + std::string FeatName = documentOfBody->getUniqueObjectName("Sketch"); + std::string supportString = Gui::Command::getObjectCmd(plane,"(",",[''])"); + + FCMD_OBJ_CMD(partDesignBody,"newObject('Sketcher::SketchObject','" << FeatName << "')"); + auto Feat = partDesignBody->getDocument()->getObject(FeatName.c_str()); + FCMD_OBJ_CMD(Feat,"Support = " << supportString); + FCMD_OBJ_CMD(Feat,"MapMode = '" << Attacher::AttachEngine::getModeName(Attacher::mmFlatFace)<<"'"); + Gui::Command::updateActive(); // Make sure the Support's Placement property is updated + PartDesignGui::setEdit(Feat, partDesignBody); + } + +private: + Gui::Document* guidocument; + PartDesign::Body* activeBody; +}; + +} + +SketchWorkflow::SketchWorkflow(Gui::Document* document) + : guidocument(document) + , activeBody(nullptr) +{ + appdocument = guidocument->getDocument(); +} + +void SketchWorkflow::createSketch() +{ + try { + tryCreateSketch(); + } + catch (const RejectException&) { + + } + catch (const WrongSelectionException&) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("Several sub-elements selected"), + QObject::tr("You have to select a single face as support for a sketch!")); + } + catch (const WrongSupportException&) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No support face selected"), + QObject::tr("You have to select a face as support for a sketch!")); + } + catch (const SupportNotPlanarException&) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No planar support"), + QObject::tr("You need a planar face as support for a sketch!")); + } + catch (const MissingPlanesException&) { + QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No valid planes in this document"), + QObject::tr("Please create a plane first or select a face to sketch on")); + } +} + +void SketchWorkflow::tryCreateSketch() +{ + if (PartDesignGui::assureModernWorkflow(appdocument)) { + createSketchWithModernWorkflow(); + } + // No PartDesign feature without Body past FreeCAD 0.13 + else if (PartDesignGui::isLegacyWorkflow(appdocument)) { + createSketchWithLegacyWorkflow(); + } +} + +std::tuple SketchWorkflow::shouldCreateBody() +{ + auto shouldMakeBody{false}; + + // We need either an active Body, or for there to be no Body + // objects (in which case, just make one) to make a new sketch. + PartDesign::Body* pdBody = PartDesignGui::getBody(/* messageIfNot = */ false); + if (!pdBody) { + if (appdocument->countObjectsOfType(PartDesign::Body::getClassTypeId()) == 0) { + shouldMakeBody = true; + } + else { + PartDesignGui::DlgActiveBody dia(Gui::getMainWindow(), appdocument); + if (dia.exec() == QDialog::Accepted) { + pdBody = dia.getActiveBody(); + } + } + } + + return std::make_tuple(shouldMakeBody, pdBody); +} + +bool SketchWorkflow::shouldAbort(bool shouldMakeBody) const +{ + return !shouldMakeBody && !activeBody; +} + +std::tuple SketchWorkflow::getFaceAndPlaneFilter() const +{ + // Hint: + // The behaviour of this command has changed with respect to a selected sketch: + // It doesn't try any more to edit a selected sketch but always tries to create + // a new sketch. + // See https://forum.freecadweb.org/viewtopic.php?f=3&t=44070 + + Gui::SelectionFilter FaceFilter ("SELECT Part::Feature SUBELEMENT Face COUNT 1"); + Gui::SelectionFilter PlaneFilter ("SELECT App::Plane COUNT 1"); + Gui::SelectionFilter PlaneFilter2("SELECT PartDesign::Plane COUNT 1"); + + if (PlaneFilter2.match()) { + PlaneFilter = PlaneFilter2; + } + return std::make_tuple(FaceFilter, PlaneFilter); +} + +void SketchWorkflow::createSketchWithModernWorkflow() +{ + auto result = shouldCreateBody(); + auto shouldMakeBody = std::get<0>(result); + activeBody = std::get<1>(result); + if (shouldAbort(shouldMakeBody)) { + return; + } + + auto faceOrPlaneFilter = getFaceAndPlaneFilter(); + SketchPreselection sketchOnFace{guidocument, activeBody, faceOrPlaneFilter}; + + if (sketchOnFace.matches()) { + // create Sketch on Face or Plane + sketchOnFace.createSupport(); + sketchOnFace.createSketchOnSupport(sketchOnFace.getSupport()); + } + else { + SketchRequestSelection requestSelection{guidocument, activeBody}; + requestSelection.findSupport(); + } +} + +void SketchWorkflow::createSketchWithLegacyWorkflow() +{ + Gui::CommandManager& cmdMgr = Gui::Application::Instance->commandManager(); + cmdMgr.runCommandByName("Sketcher_NewSketch"); +} diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.h b/src/Mod/PartDesign/Gui/SketchWorkflow.h new file mode 100644 index 0000000000..145fbcbc5d --- /dev/null +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.h @@ -0,0 +1,65 @@ +/************************************************************************** +* Copyright (c) 2022 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 * +* * +***************************************************************************/ + +#ifndef PARTDESIGNGUI_SKETCHWORKFLOW_H +#define PARTDESIGNGUI_SKETCHWORKFLOW_H + +#include +#include +#include + +namespace App { +class Document; +class DocumentObject; +class GeoFeatureGroupExtension; +} +namespace Gui { +class Document; +} +namespace PartDesign { +class Body; +} +namespace PartDesignGui { + +class SketchWorkflow +{ +public: + SketchWorkflow(Gui::Document*); + void createSketch(); + +private: + void tryCreateSketch(); + void createSketchWithModernWorkflow(); + void createSketchWithLegacyWorkflow(); + std::tuple shouldCreateBody(); + bool shouldAbort(bool) const; + std::tuple getFaceAndPlaneFilter() const; + +private: + Gui::Document* guidocument; + App::Document* appdocument; + PartDesign::Body* activeBody; +}; + +} // namespace PartDesignGui + +#endif // PARTDESIGNGUI_SKETCHWORKFLOW_H From 8d6ea90cee7b7715f939ecc41ccb011098654489 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 23:07:41 +0100 Subject: [PATCH 08/26] [MeshPart] improve PreCompiled.h handling --- .../App/MeshFlatteningBoostPython.cpp | 16 +- src/Mod/MeshPart/App/Mesher.cpp | 1 + src/Mod/MeshPart/App/PreCompiled.cpp | 1 - src/Mod/MeshPart/App/PreCompiled.h | 171 ++---------------- src/Mod/MeshPart/Gui/CurveOnMesh.cpp | 24 +-- src/Mod/MeshPart/Gui/PreCompiled.cpp | 1 - src/Mod/MeshPart/Gui/PreCompiled.h | 31 ++-- 7 files changed, 55 insertions(+), 190 deletions(-) diff --git a/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp b/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp index 08b210ef9a..c7023b7a57 100644 --- a/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp +++ b/src/Mod/MeshPart/App/MeshFlatteningBoostPython.cpp @@ -26,18 +26,20 @@ # include # include # include + # include # include # include + +# include +# include +# include +# include +# include +# include +# include #endif -#include -#include -#include -#include -#include -#include -#include #include #include #include diff --git a/src/Mod/MeshPart/App/Mesher.cpp b/src/Mod/MeshPart/App/Mesher.cpp index 0dc4270c73..ff29561a86 100644 --- a/src/Mod/MeshPart/App/Mesher.cpp +++ b/src/Mod/MeshPart/App/Mesher.cpp @@ -23,6 +23,7 @@ #include "PreCompiled.h" #ifndef _PreComp_ # include + # include # include # include diff --git a/src/Mod/MeshPart/App/PreCompiled.cpp b/src/Mod/MeshPart/App/PreCompiled.cpp index 7cd1cae80f..cde4369c5b 100644 --- a/src/Mod/MeshPart/App/PreCompiled.cpp +++ b/src/Mod/MeshPart/App/PreCompiled.cpp @@ -20,5 +20,4 @@ * * ***************************************************************************/ - #include "PreCompiled.h" diff --git a/src/Mod/MeshPart/App/PreCompiled.h b/src/Mod/MeshPart/App/PreCompiled.h index 57c51bbb2d..efeec9db94 100644 --- a/src/Mod/MeshPart/App/PreCompiled.h +++ b/src/Mod/MeshPart/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef __PRECOMPILED__ #define __PRECOMPILED__ @@ -36,193 +35,57 @@ #ifdef _PreComp_ // standard +#include +#include + +// STL #include #include -#include -#include -#include -#include -#include #include #include #include #include #include -#include #include -// OpenCasCade ===================================================================================== -// Base -#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 -#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 -#include -#include -#include -#include +// boost +#include +#include +#include +#include +#include +#include +#include +// OpenCasCade #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 -#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 -#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 #include #include -#include #include #include -#include -#include #include -#include -#include -#include -#include -#include - -#include #endif // _PreComp_ #endif - diff --git a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp index 4abb5f5f20..3ec8775549 100644 --- a/src/Mod/MeshPart/Gui/CurveOnMesh.cpp +++ b/src/Mod/MeshPart/Gui/CurveOnMesh.cpp @@ -27,7 +27,19 @@ # include # include # include + +# include +# include +# include +# include +# include +# include # include +# include +# include +# include +# include + # include # include # include @@ -67,17 +79,7 @@ #define HAVE_ATANH #endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include + /* XPM */ static const char *cursor_curveonmesh[]={ diff --git a/src/Mod/MeshPart/Gui/PreCompiled.cpp b/src/Mod/MeshPart/Gui/PreCompiled.cpp index 7cd1cae80f..cde4369c5b 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.cpp +++ b/src/Mod/MeshPart/Gui/PreCompiled.cpp @@ -20,5 +20,4 @@ * * ***************************************************************************/ - #include "PreCompiled.h" diff --git a/src/Mod/MeshPart/Gui/PreCompiled.h b/src/Mod/MeshPart/Gui/PreCompiled.h index 70dcb83749..fe28f65378 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.h +++ b/src/Mod/MeshPart/Gui/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef __PRECOMPILED_GUI__ #define __PRECOMPILED_GUI__ @@ -34,34 +33,34 @@ #ifdef _PreComp_ -// standard -#include -#include -#include - // STL -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include #ifdef FC_OS_WIN32 # include #endif - // Qt Toolkit #ifndef __QtAll__ # include #endif // OCCT +#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif //_PreComp_ From 3e33a91aa9fc81e9d5f4c6f99181273761ee0ab1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 8 Dec 2022 00:09:48 +0100 Subject: [PATCH 09/26] PD: fixes #6000: auto-generated Body not placed under existing Part --- src/Mod/PartDesign/Gui/SketchWorkflow.cpp | 26 +++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp index 6b56e7af7c..829aee9736 100644 --- a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp @@ -258,12 +258,23 @@ private: { if (!activeBody) { activeBody = PartDesignGui::getBody( /* messageIfNot = */ true ); - if (!activeBody) { + if (activeBody) { + tryAddNewBodyToActivePart(); + } + else { throw RejectException(); } } } + void tryAddNewBodyToActivePart() + { + App::Part *activePart = PartDesignGui::getActivePart(); + if (activePart) { + activePart->addObject(activeBody); + } + } + void handleIfSupportOutOfBody(App::DocumentObject* selectedObject) { if (!activeBody->hasObject(selectedObject)) { @@ -498,12 +509,23 @@ private: if (!activeBody) { App::Document* appdocument = guidocument->getDocument(); activeBody = PartDesignGui::makeBody(appdocument); - if (!activeBody) { + if (activeBody) { + tryAddNewBodyToActivePart(); + } + else { throw RejectException(); } } } + void tryAddNewBodyToActivePart() + { + App::Part *activePart = PartDesignGui::getActivePart(); + if (activePart) { + activePart->addObject(activeBody); + } + } + void findAndSelectPlane() { App::Document* appdocument = guidocument->getDocument(); From df1e0b5be81287580031e1901db4ed4c1b97af50 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 8 Dec 2022 00:26:35 +0100 Subject: [PATCH 10/26] PD: [skip ci] Single-parameter constructors should be marked explicit --- src/Mod/PartDesign/Gui/SketchWorkflow.cpp | 8 ++++---- src/Mod/PartDesign/Gui/SketchWorkflow.h | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp index 829aee9736..30c8bcc92f 100644 --- a/src/Mod/PartDesign/Gui/SketchWorkflow.cpp +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.cpp @@ -86,7 +86,7 @@ struct MissingPlanesException class SupportFaceValidator { public: - SupportFaceValidator(Gui::SelectionObject faceSelection) + explicit SupportFaceValidator(Gui::SelectionObject faceSelection) : faceSelection(faceSelection) { } @@ -172,7 +172,7 @@ private: class SupportPlaneValidator { public: - SupportPlaneValidator(Gui::SelectionObject faceSelection) + explicit SupportPlaneValidator(Gui::SelectionObject faceSelection) : faceSelection(faceSelection) { } @@ -195,7 +195,7 @@ class SketchPreselection { public: SketchPreselection(Gui::Document* guidocument, PartDesign::Body* activeBody, - std::tuple filter) + std::tuple filter) : guidocument(guidocument) , activeBody(activeBody) , faceFilter(std::get<0>(filter)) @@ -386,7 +386,7 @@ public: { App::GeoFeatureGroupExtension *geoGroup = getGroupExtensionOfBody(); auto datumPlanes( appdocument->getObjectsOfType(PartDesign::Plane::getClassTypeId()) ); - for (auto plane: datumPlanes) { + for (auto plane : datumPlanes) { planes.push_back ( plane ); // Check whether this plane belongs to the active body if ( activeBody->hasObject(plane) ) { diff --git a/src/Mod/PartDesign/Gui/SketchWorkflow.h b/src/Mod/PartDesign/Gui/SketchWorkflow.h index 145fbcbc5d..97ce53b6f3 100644 --- a/src/Mod/PartDesign/Gui/SketchWorkflow.h +++ b/src/Mod/PartDesign/Gui/SketchWorkflow.h @@ -43,7 +43,7 @@ namespace PartDesignGui { class SketchWorkflow { public: - SketchWorkflow(Gui::Document*); + explicit SketchWorkflow(Gui::Document*); void createSketch(); private: From 3b1580136b35a2054b9c3d5297c2847f7ad77076 Mon Sep 17 00:00:00 2001 From: Uwe Date: Wed, 7 Dec 2022 23:46:21 +0100 Subject: [PATCH 11/26] [Surface] App:: remove unused includes - also some sorting --- src/Gui/InventorAll.h | 8 +++++ src/Mod/Part/App/OpenCascadeAll.h | 1 + src/Mod/Surface/App/AppSurface.cpp | 7 ++-- src/Mod/Surface/App/FeatureCut.cpp | 13 ++------ src/Mod/Surface/App/FeatureCut.h | 3 +- src/Mod/Surface/App/FeatureExtend.cpp | 33 ++++++++++--------- src/Mod/Surface/App/FeatureExtend.h | 3 +- src/Mod/Surface/App/FeatureFilling.cpp | 22 +++++-------- src/Mod/Surface/App/FeatureFilling.h | 3 +- .../Surface/App/FeatureGeomFillSurface.cpp | 16 ++++----- src/Mod/Surface/App/FeatureGeomFillSurface.h | 9 +++-- src/Mod/Surface/App/FeatureSections.cpp | 23 ++++++------- src/Mod/Surface/App/FeatureSections.h | 3 +- src/Mod/Surface/App/FeatureSewing.cpp | 13 +++----- src/Mod/Surface/App/FeatureSewing.h | 3 +- src/Mod/Surface/App/PreCompiled.cpp | 1 - src/Mod/Surface/App/PreCompiled.h | 18 +--------- 17 files changed, 70 insertions(+), 109 deletions(-) diff --git a/src/Gui/InventorAll.h b/src/Gui/InventorAll.h index bf30ee87e2..b0310a850d 100644 --- a/src/Gui/InventorAll.h +++ b/src/Gui/InventorAll.h @@ -98,6 +98,7 @@ #include #include #include +#include #include #include #include @@ -110,9 +111,11 @@ #include #include #include +#include #include #include #include +#include #include #include #include @@ -136,6 +139,7 @@ #include #include #include +#include #include #include #include @@ -149,6 +153,7 @@ #include #include #include +#include #include #include #include @@ -173,6 +178,7 @@ #include #include #include +#include #include #include #include @@ -183,6 +189,7 @@ #include #include #include +#include #include #include #include @@ -201,6 +208,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index 475b1704ee..fa9716129d 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -308,6 +308,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Mod/Surface/App/AppSurface.cpp b/src/Mod/Surface/App/AppSurface.cpp index 02349b5af6..cb5ab8282e 100644 --- a/src/Mod/Surface/App/AppSurface.cpp +++ b/src/Mod/Surface/App/AppSurface.cpp @@ -23,11 +23,13 @@ #include "PreCompiled.h" #include -#include +#include +#include #include "Blending/BlendCurvePy.h" #include "Blending/BlendPointPy.h" #include "Blending/FeatureBlendCurve.h" + #include "FeatureCut.h" #include "FeatureExtend.h" #include "FeatureFilling.h" @@ -35,9 +37,6 @@ #include "FeatureSections.h" #include "FeatureSewing.h" -#include -#include - namespace Surface { diff --git a/src/Mod/Surface/App/FeatureCut.cpp b/src/Mod/Surface/App/FeatureCut.cpp index fbc7711a6e..1d3401728d 100644 --- a/src/Mod/Surface/App/FeatureCut.cpp +++ b/src/Mod/Surface/App/FeatureCut.cpp @@ -22,20 +22,11 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include -#include -#include -#include +# include #endif #include "FeatureCut.h" -#include -#include -#include -#include -#include -#include -#include + using namespace Surface; diff --git a/src/Mod/Surface/App/FeatureCut.h b/src/Mod/Surface/App/FeatureCut.h index 12dfc1fe4a..3f5227dbc0 100644 --- a/src/Mod/Surface/App/FeatureCut.h +++ b/src/Mod/Surface/App/FeatureCut.h @@ -23,12 +23,11 @@ #ifndef SURFACE_FEATURECUT_H #define SURFACE_FEATURECUT_H -#include -#include #include #include #include + namespace Surface { diff --git a/src/Mod/Surface/App/FeatureExtend.cpp b/src/Mod/Surface/App/FeatureExtend.cpp index 87877785d0..d2c14d7792 100644 --- a/src/Mod/Surface/App/FeatureExtend.cpp +++ b/src/Mod/Surface/App/FeatureExtend.cpp @@ -22,28 +22,29 @@ #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 +# include +# include #endif -#include "FeatureExtend.h" #include -#include + +#include "FeatureExtend.h" + using namespace Surface; -const App::PropertyIntegerConstraint::Constraints SampleRange = {2,INT_MAX,1}; -const App::PropertyFloatConstraint::Constraints ToleranceRange = {0.0,10.0,0.01}; -const App::PropertyFloatConstraint::Constraints ExtendRange = {-0.5,10.0,0.01}; +const App::PropertyIntegerConstraint::Constraints SampleRange = {2, INT_MAX, 1}; +const App::PropertyFloatConstraint::Constraints ToleranceRange = {0.0, 10.0, 0.01}; +const App::PropertyFloatConstraint::Constraints ExtendRange = {-0.5, 10.0, 0.01}; PROPERTY_SOURCE(Surface::Extend, Part::Spline) Extend::Extend() : lockOnChangeMutex(false) diff --git a/src/Mod/Surface/App/FeatureExtend.h b/src/Mod/Surface/App/FeatureExtend.h index b682531a25..c80d483d46 100644 --- a/src/Mod/Surface/App/FeatureExtend.h +++ b/src/Mod/Surface/App/FeatureExtend.h @@ -23,12 +23,11 @@ #ifndef SURFACE_FEATUREEXTEND_H #define SURFACE_FEATUREEXTEND_H -#include -#include #include #include #include + namespace Surface { diff --git a/src/Mod/Surface/App/FeatureFilling.cpp b/src/Mod/Surface/App/FeatureFilling.cpp index eee6ef5476..a3d6512fbf 100644 --- a/src/Mod/Surface/App/FeatureFilling.cpp +++ b/src/Mod/Surface/App/FeatureFilling.cpp @@ -22,22 +22,18 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +# include + +# include +# include +# include +# include +# include +# include #endif #include "FeatureFilling.h" -#include -#include -#include + using namespace Surface; diff --git a/src/Mod/Surface/App/FeatureFilling.h b/src/Mod/Surface/App/FeatureFilling.h index f757918d9a..902d5f2d46 100644 --- a/src/Mod/Surface/App/FeatureFilling.h +++ b/src/Mod/Surface/App/FeatureFilling.h @@ -23,12 +23,11 @@ #ifndef SURFACE_FEATUREFILLING_H #define SURFACE_FEATUREFILLING_H -#include -#include #include #include #include + class BRepFill_Filling; namespace Surface diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp index 0171a01fc2..1b5e5b4fa3 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.cpp +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.cpp @@ -25,14 +25,8 @@ #ifndef _PreComp_ #include -#include -#include -#include -#include -#include -#include -#include #include +#include #include #include #include @@ -49,13 +43,15 @@ #include #include #include +#include +#include +#include +#include #endif -#include -#include - #include "FeatureGeomFillSurface.h" + using namespace Surface; ShapeValidator::ShapeValidator() diff --git a/src/Mod/Surface/App/FeatureGeomFillSurface.h b/src/Mod/Surface/App/FeatureGeomFillSurface.h index 908ef9413c..bf1dc2974b 100644 --- a/src/Mod/Surface/App/FeatureGeomFillSurface.h +++ b/src/Mod/Surface/App/FeatureGeomFillSurface.h @@ -24,15 +24,14 @@ #ifndef FEATUREGEOMFILLSURFACE_H #define FEATUREGEOMFILLSURFACE_H +#include +#include +#include + #include #include #include -#include -#include -#include -#include -#include namespace Surface { diff --git a/src/Mod/Surface/App/FeatureSections.cpp b/src/Mod/Surface/App/FeatureSections.cpp index 313569784d..e38dff8ec0 100644 --- a/src/Mod/Surface/App/FeatureSections.cpp +++ b/src/Mod/Surface/App/FeatureSections.cpp @@ -22,22 +22,19 @@ #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 #endif #include "FeatureSections.h" -#include -#include + using namespace Surface; diff --git a/src/Mod/Surface/App/FeatureSections.h b/src/Mod/Surface/App/FeatureSections.h index 250af07359..f7abbc457b 100644 --- a/src/Mod/Surface/App/FeatureSections.h +++ b/src/Mod/Surface/App/FeatureSections.h @@ -23,12 +23,11 @@ #ifndef SURFACE_FEATURESECTIONS_H #define SURFACE_FEATURESECTIONS_H -#include -#include #include #include #include + namespace Surface { diff --git a/src/Mod/Surface/App/FeatureSewing.cpp b/src/Mod/Surface/App/FeatureSewing.cpp index 0c6be1a676..52670653d6 100644 --- a/src/Mod/Surface/App/FeatureSewing.cpp +++ b/src/Mod/Surface/App/FeatureSewing.cpp @@ -22,18 +22,13 @@ #include "PreCompiled.h" #ifndef _PreComp_ -#include -#include -#include -#include +# include +# include +# include #endif #include "FeatureSewing.h" -#include -#include -#include -#include -#include + using namespace Surface; diff --git a/src/Mod/Surface/App/FeatureSewing.h b/src/Mod/Surface/App/FeatureSewing.h index 1f0b7a0f92..d2b8cd262f 100644 --- a/src/Mod/Surface/App/FeatureSewing.h +++ b/src/Mod/Surface/App/FeatureSewing.h @@ -24,11 +24,10 @@ #define SURFACE_FEATURESEWING_H #include -#include -#include #include #include + namespace Surface { diff --git a/src/Mod/Surface/App/PreCompiled.cpp b/src/Mod/Surface/App/PreCompiled.cpp index cfd0e9a769..a6ded796a3 100644 --- a/src/Mod/Surface/App/PreCompiled.cpp +++ b/src/Mod/Surface/App/PreCompiled.cpp @@ -20,5 +20,4 @@ * * ***************************************************************************/ - #include "PreCompiled.h" diff --git a/src/Mod/Surface/App/PreCompiled.h b/src/Mod/Surface/App/PreCompiled.h index edc8ffc830..0ae0ad59e7 100644 --- a/src/Mod/Surface/App/PreCompiled.h +++ b/src/Mod/Surface/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef PRECOMPILED_H #define PRECOMPILED_H @@ -28,26 +27,11 @@ #ifdef _PreComp_ -// standard -#include -#include -#include - // STL -#include -#include -#include -#include -#include -#include -#include -#include #include -#include //opencascade -#include "OpenCascadeAll.h" -#include +#include #endif //_PreComp_ From 58d8b36dfdddcfd730c980525aa75d8ecf7e4576 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 00:47:02 +0100 Subject: [PATCH 12/26] [Surface] Gui:: remove unused includes - also some sorting --- src/Mod/Surface/Gui/AppSurfaceGui.cpp | 1 + src/Mod/Surface/Gui/Command.cpp | 38 +++++---------------- src/Mod/Surface/Gui/PreCompiled.cpp | 1 - src/Mod/Surface/Gui/PreCompiled.h | 35 +++++++++---------- src/Mod/Surface/Gui/TaskFilling.cpp | 33 +++++++++--------- src/Mod/Surface/Gui/TaskFilling.h | 5 ++- src/Mod/Surface/Gui/TaskFillingEdge.cpp | 26 +++++++------- src/Mod/Surface/Gui/TaskFillingEdge.h | 7 ++-- src/Mod/Surface/Gui/TaskFillingVertex.cpp | 19 +++-------- src/Mod/Surface/Gui/TaskFillingVertex.h | 7 ++-- src/Mod/Surface/Gui/TaskGeomFillSurface.cpp | 26 +++++++------- src/Mod/Surface/Gui/TaskGeomFillSurface.h | 8 ++--- src/Mod/Surface/Gui/TaskSections.cpp | 27 +++++++-------- src/Mod/Surface/Gui/TaskSections.h | 8 ++--- src/Mod/Surface/Gui/ViewProviderExtend.cpp | 2 +- src/Mod/Surface/Gui/ViewProviderExtend.h | 2 +- src/Mod/Surface/Gui/Workbench.cpp | 8 ++--- 17 files changed, 105 insertions(+), 148 deletions(-) diff --git a/src/Mod/Surface/Gui/AppSurfaceGui.cpp b/src/Mod/Surface/Gui/AppSurfaceGui.cpp index 5bc15816f9..f8d024109b 100644 --- a/src/Mod/Surface/Gui/AppSurfaceGui.cpp +++ b/src/Mod/Surface/Gui/AppSurfaceGui.cpp @@ -29,6 +29,7 @@ #include #include "Blending/ViewProviderBlendCurve.h" + #include "TaskFilling.h" #include "TaskGeomFillSurface.h" #include "TaskSections.h" diff --git a/src/Mod/Surface/Gui/Command.cpp b/src/Mod/Surface/Gui/Command.cpp index c163af04fd..ff650769aa 100644 --- a/src/Mod/Surface/Gui/Command.cpp +++ b/src/Mod/Surface/Gui/Command.cpp @@ -23,46 +23,24 @@ #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 +# include +# include +# include #endif -#include #include #include -#include #include #include -#include -#include #include -#include #include #include -#include -#include -#include - -#include -#include -#include #include "Mod/Part/App/PartFeature.h" -#include -#include //=========================================================================== diff --git a/src/Mod/Surface/Gui/PreCompiled.cpp b/src/Mod/Surface/Gui/PreCompiled.cpp index cfd0e9a769..a6ded796a3 100644 --- a/src/Mod/Surface/Gui/PreCompiled.cpp +++ b/src/Mod/Surface/Gui/PreCompiled.cpp @@ -20,5 +20,4 @@ * * ***************************************************************************/ - #include "PreCompiled.h" diff --git a/src/Mod/Surface/Gui/PreCompiled.h b/src/Mod/Surface/Gui/PreCompiled.h index 16d8beb03a..423211b18f 100644 --- a/src/Mod/Surface/Gui/PreCompiled.h +++ b/src/Mod/Surface/Gui/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef GUI_PRECOMPILED_H #define GUI_PRECOMPILED_H @@ -28,30 +27,30 @@ #ifdef _PreComp_ -// standard -#include -#include - // STL -#include -#include -#include -#include -#include -#include #include -#include -#include -#include #ifdef FC_OS_WIN32 # include #endif -// Qt Toolkit -#ifndef __QtAll__ -# include -#endif +// Qt +#include +#include +#include +#include +#include + +// OpenCasCade +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif //_PreComp_ diff --git a/src/Mod/Surface/Gui/TaskFilling.cpp b/src/Mod/Surface/Gui/TaskFilling.cpp index 4c01b677a2..3b30ca9c58 100644 --- a/src/Mod/Surface/Gui/TaskFilling.cpp +++ b/src/Mod/Surface/Gui/TaskFilling.cpp @@ -21,31 +21,32 @@ ***************************************************************************/ #include "PreCompiled.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +# include +# include + +# include +# include +# include +# include +# include +#endif -#include #include -#include #include -#include -#include -#include -#include #include +#include +#include +#include +#include #include #include "TaskFilling.h" +#include "ui_TaskFilling.h" #include "TaskFillingEdge.h" #include "TaskFillingVertex.h" -#include "ui_TaskFilling.h" using namespace SurfaceGui; diff --git a/src/Mod/Surface/Gui/TaskFilling.h b/src/Mod/Surface/Gui/TaskFilling.h index d4abb9e8c8..91d1f1376a 100644 --- a/src/Mod/Surface/Gui/TaskFilling.h +++ b/src/Mod/Surface/Gui/TaskFilling.h @@ -23,14 +23,13 @@ #ifndef SURFACEGUI_TASKFILLING_H #define SURFACEGUI_TASKFILLING_H +#include #include #include -#include -#include -#include #include #include + class QListWidgetItem; namespace SurfaceGui diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.cpp b/src/Mod/Surface/Gui/TaskFillingEdge.cpp index 58e6b7fdb5..54c24d1171 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.cpp +++ b/src/Mod/Surface/Gui/TaskFillingEdge.cpp @@ -22,25 +22,23 @@ ***************************************************************************/ #include "PreCompiled.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +# include + +# include +# include +# include +# include +# include +#endif #include -#include #include -#include #include +#include #include -#include -#include -#include #include #include "TaskFillingEdge.h" diff --git a/src/Mod/Surface/Gui/TaskFillingEdge.h b/src/Mod/Surface/Gui/TaskFillingEdge.h index 53fd2146b5..d2f67c295b 100644 --- a/src/Mod/Surface/Gui/TaskFillingEdge.h +++ b/src/Mod/Surface/Gui/TaskFillingEdge.h @@ -24,14 +24,11 @@ #ifndef SURFACEGUI_TASKFILLINGEDGE_H #define SURFACEGUI_TASKFILLINGEDGE_H -#include -#include -#include #include -#include -#include +#include #include + class QListWidgetItem; namespace SurfaceGui diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.cpp b/src/Mod/Surface/Gui/TaskFillingVertex.cpp index 7d9a606796..d0cdd02db4 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.cpp +++ b/src/Mod/Surface/Gui/TaskFillingVertex.cpp @@ -21,25 +21,16 @@ ***************************************************************************/ #include "PreCompiled.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +#endif #include -#include #include -#include #include +#include #include -#include -#include -#include #include #include "TaskFillingVertex.h" diff --git a/src/Mod/Surface/Gui/TaskFillingVertex.h b/src/Mod/Surface/Gui/TaskFillingVertex.h index bbc1052c5a..a52740dd10 100644 --- a/src/Mod/Surface/Gui/TaskFillingVertex.h +++ b/src/Mod/Surface/Gui/TaskFillingVertex.h @@ -23,14 +23,11 @@ #ifndef SURFACEGUI_TASKFILLINGVERTEX_H #define SURFACEGUI_TASKFILLINGVERTEX_H -#include -#include -#include #include -#include -#include +#include #include + class QListWidgetItem; namespace SurfaceGui diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp index f04494a796..334ece5630 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.cpp @@ -22,22 +22,24 @@ ***************************************************************************/ #include "PreCompiled.h" -#include -#include -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +# include +# include + +# include +# include +#endif #include -#include -#include -#include -#include -#include #include -#include +#include #include +#include +#include +#include +#include #include #include "TaskGeomFillSurface.h" diff --git a/src/Mod/Surface/Gui/TaskGeomFillSurface.h b/src/Mod/Surface/Gui/TaskGeomFillSurface.h index ba83cd2835..cbc43508b1 100644 --- a/src/Mod/Surface/Gui/TaskGeomFillSurface.h +++ b/src/Mod/Surface/Gui/TaskGeomFillSurface.h @@ -23,14 +23,14 @@ #ifndef SURFACEGUI_TASKGEOMFILLSURFACE_H #define SURFACEGUI_TASKGEOMFILLSURFACE_H +#include + +#include #include #include -#include -#include -#include #include #include -#include + class QListWidgetItem; diff --git a/src/Mod/Surface/Gui/TaskSections.cpp b/src/Mod/Surface/Gui/TaskSections.cpp index 349710ff0c..d76bdada5d 100644 --- a/src/Mod/Surface/Gui/TaskSections.cpp +++ b/src/Mod/Surface/Gui/TaskSections.cpp @@ -21,25 +21,22 @@ ***************************************************************************/ #include "PreCompiled.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include +#ifndef _PreComp_ +# include +# include +# include +# include + +# include +# include +#endif #include -#include #include -#include -#include -#include -#include -#include #include +#include +#include +#include #include #include "TaskSections.h" diff --git a/src/Mod/Surface/Gui/TaskSections.h b/src/Mod/Surface/Gui/TaskSections.h index 629dfc43e4..6bcb958223 100644 --- a/src/Mod/Surface/Gui/TaskSections.h +++ b/src/Mod/Surface/Gui/TaskSections.h @@ -23,14 +23,14 @@ #ifndef SURFACEGUI_TASKSECTIONS_H #define SURFACEGUI_TASKSECTIONS_H +#include + +#include #include #include -#include -#include -#include #include #include -#include + class QListWidgetItem; diff --git a/src/Mod/Surface/Gui/ViewProviderExtend.cpp b/src/Mod/Surface/Gui/ViewProviderExtend.cpp index 5d575c48f6..faaaf28891 100644 --- a/src/Mod/Surface/Gui/ViewProviderExtend.cpp +++ b/src/Mod/Surface/Gui/ViewProviderExtend.cpp @@ -23,10 +23,10 @@ #include "PreCompiled.h" #include -#include #include "ViewProviderExtend.h" + using namespace SurfaceGui; PROPERTY_SOURCE(SurfaceGui::ViewProviderExtend, PartGui::ViewProviderSpline) diff --git a/src/Mod/Surface/Gui/ViewProviderExtend.h b/src/Mod/Surface/Gui/ViewProviderExtend.h index 7f5f18c415..a90a226e65 100644 --- a/src/Mod/Surface/Gui/ViewProviderExtend.h +++ b/src/Mod/Surface/Gui/ViewProviderExtend.h @@ -24,7 +24,7 @@ #define SURFACEGUI_VIEWPROVIDEREXTEND_H #include -#include + namespace SurfaceGui { diff --git a/src/Mod/Surface/Gui/Workbench.cpp b/src/Mod/Surface/Gui/Workbench.cpp index a16839b6f4..d2241ea0bc 100644 --- a/src/Mod/Surface/Gui/Workbench.cpp +++ b/src/Mod/Surface/Gui/Workbench.cpp @@ -21,16 +21,14 @@ * * ***************************************************************************/ - #include "PreCompiled.h" -#ifndef _PreComp_ -#endif - -#include "Workbench.h" #include #include +#include "Workbench.h" + + using namespace SurfaceGui; /// @namespace SurfaceGui @class Workbench From ffe5c754af6d0e907f087adf52a4569c0227283b Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 01:02:52 +0100 Subject: [PATCH 13/26] [Sketch] App: improve PreCompiled.h handling --- src/Mod/Part/App/OpenCascadeAll.h | 2 + .../Sketcher/App/ExternalGeometryFacade.cpp | 5 +-- src/Mod/Sketcher/App/GeometryFacade.cpp | 5 +-- src/Mod/Sketcher/App/PreCompiled.h | 45 +++++-------------- src/Mod/Sketcher/App/PythonConverter.cpp | 5 +-- 5 files changed, 19 insertions(+), 43 deletions(-) diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index fa9716129d..0ae278a9ed 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -177,6 +177,7 @@ #include #include #include +#include #include #include @@ -297,6 +298,7 @@ #include #include #include +#include #include #include #include diff --git a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp index 7e11451732..4f0a69aefe 100644 --- a/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp +++ b/src/Mod/Sketcher/App/ExternalGeometryFacade.cpp @@ -20,17 +20,16 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ - +# include #endif #include "ExternalGeometryFacade.h" #include // Only for Debug - To be removed #include -#include + #include "ExternalGeometryFacadePy.h" diff --git a/src/Mod/Sketcher/App/GeometryFacade.cpp b/src/Mod/Sketcher/App/GeometryFacade.cpp index 8137f767ce..b5dae65f32 100644 --- a/src/Mod/Sketcher/App/GeometryFacade.cpp +++ b/src/Mod/Sketcher/App/GeometryFacade.cpp @@ -20,17 +20,16 @@ * * ***************************************************************************/ - #include "PreCompiled.h" #ifndef _PreComp_ - +# include #endif #include "GeometryFacade.h" //#include // Only for Debug, when/if necessary #include -#include + #include "GeometryFacadePy.h" diff --git a/src/Mod/Sketcher/App/PreCompiled.h b/src/Mod/Sketcher/App/PreCompiled.h index becbfd4898..bf41f16fa2 100644 --- a/src/Mod/Sketcher/App/PreCompiled.h +++ b/src/Mod/Sketcher/App/PreCompiled.h @@ -20,7 +20,6 @@ * * ***************************************************************************/ - #ifndef __PRECOMPILED__ #define __PRECOMPILED__ @@ -29,53 +28,33 @@ #ifdef _PreComp_ // standard -#include -#include -#include +#include +#include +#include #include -#include #include #include -#include +#include #include -#include - -#include -#include +#include +#include +#include // QT #include // Boost -#include +#include +#include // Opencascade #include -// Other needed opencascade -# include -# include -# include -# include -# include -# include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - - #elif defined(FC_OS_WIN32) #ifndef NOMINMAX -#define NOMINMAX +# define NOMINMAX #endif -#include +# include #endif // _PreComp_ -#endif +#endif diff --git a/src/Mod/Sketcher/App/PythonConverter.cpp b/src/Mod/Sketcher/App/PythonConverter.cpp index 4d75f1b085..cbde8faa48 100644 --- a/src/Mod/Sketcher/App/PythonConverter.cpp +++ b/src/Mod/Sketcher/App/PythonConverter.cpp @@ -20,14 +20,11 @@ * * ***************************************************************************/ - #include "PreCompiled.h" - #ifndef _PreComp_ +# include #endif // #ifndef _PreComp_ -#include - #include #include From ee7e19fac0619a12d7e370d4e3fd2b2c38d12698 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 02:10:46 +0100 Subject: [PATCH 14/26] [Spread] App: enable precompiled headers --- src/Mod/Spreadsheet/App/CMakeLists.txt | 10 ++++++++-- src/Mod/Spreadsheet/App/PreCompiled.h | 14 +++++++++----- src/Mod/Spreadsheet/App/PropertySheet.cpp | 3 ++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Mod/Spreadsheet/App/CMakeLists.txt b/src/Mod/Spreadsheet/App/CMakeLists.txt index 40b116ba8f..959ce57bd0 100644 --- a/src/Mod/Spreadsheet/App/CMakeLists.txt +++ b/src/Mod/Spreadsheet/App/CMakeLists.txt @@ -19,6 +19,8 @@ set(Spreadsheet_SRCS Cell.cpp Cell.h DisplayUnit.h + PreCompiled.cpp + PreCompiled.h PropertySheet.cpp PropertySheet.h PropertySheetPy.xml @@ -31,8 +33,6 @@ set(Spreadsheet_SRCS PropertyRowHeights.h PropertyRowHeightsPy.xml PropertyRowHeightsPyImp.cpp - PreCompiled.cpp - PreCompiled.h Sheet.cpp Sheet.h SheetPy.xml @@ -49,6 +49,12 @@ generate_from_xml(PropertySheetPy) generate_from_xml(PropertyColumnWidthsPy) generate_from_xml(PropertyRowHeightsPy) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Spreadsheet_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(Spreadsheet PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + add_library(Spreadsheet SHARED ${Spreadsheet_SRCS}) target_link_libraries(Spreadsheet ${Spreadsheet_LIBS}) diff --git a/src/Mod/Spreadsheet/App/PreCompiled.h b/src/Mod/Spreadsheet/App/PreCompiled.h index d253a5c8cb..779a2ea42f 100644 --- a/src/Mod/Spreadsheet/App/PreCompiled.h +++ b/src/Mod/Spreadsheet/App/PreCompiled.h @@ -37,6 +37,7 @@ #ifdef _PreComp_ // STL +#include #include #include #include @@ -51,13 +52,16 @@ #include #include -#ifdef FC_OS_WIN32 -# include -#endif - // Qt #include -#endif //_PreComp_ +#elif defined(FC_OS_WIN32) +#define WIN32_LEAN_AND_MEAN +#ifndef NOMINMAX +# define NOMINMAX +#endif +#include +#include +#endif//_PreComp_ #endif // SPREADSHEET_PRECOMPILED_H diff --git a/src/Mod/Spreadsheet/App/PropertySheet.cpp b/src/Mod/Spreadsheet/App/PropertySheet.cpp index 6182619095..813c1c1219 100644 --- a/src/Mod/Spreadsheet/App/PropertySheet.cpp +++ b/src/Mod/Spreadsheet/App/PropertySheet.cpp @@ -21,8 +21,9 @@ ***************************************************************************/ #include "PreCompiled.h" - #ifndef _PreComp_ +# include + # include # include # include From d6978106ea1ee8a5161f7f07ecd04827b731f3b2 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 02:46:36 +0100 Subject: [PATCH 15/26] [Spread] App: remove unnecessary Windows headers - I added this earlier today, but it is not necessary at all, tested on 2 different Win PCs --- src/Mod/Spreadsheet/App/PreCompiled.h | 7 ------- 1 file changed, 7 deletions(-) diff --git a/src/Mod/Spreadsheet/App/PreCompiled.h b/src/Mod/Spreadsheet/App/PreCompiled.h index 779a2ea42f..54e5f3f6d7 100644 --- a/src/Mod/Spreadsheet/App/PreCompiled.h +++ b/src/Mod/Spreadsheet/App/PreCompiled.h @@ -55,13 +55,6 @@ // Qt #include -#elif defined(FC_OS_WIN32) -#define WIN32_LEAN_AND_MEAN -#ifndef NOMINMAX -# define NOMINMAX -#endif -#include -#include #endif//_PreComp_ #endif // SPREADSHEET_PRECOMPILED_H From 97ee8b847f1a46696b21792073674cb19d43a5b5 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 02:43:06 +0100 Subject: [PATCH 16/26] [Surface] enable precompiled headers - also remove double code --- src/Mod/Part/App/OpenCascadeAll.h | 4 +++- .../App/Blending/FeatureBlendCurve.cpp | 9 ++++---- src/Mod/Surface/App/CMakeLists.txt | 23 +++++-------------- src/Mod/Surface/Gui/CMakeLists.txt | 6 +++++ src/Mod/Surface/Gui/PreCompiled.h | 4 ---- 5 files changed, 20 insertions(+), 26 deletions(-) diff --git a/src/Mod/Part/App/OpenCascadeAll.h b/src/Mod/Part/App/OpenCascadeAll.h index 0ae278a9ed..78f70f2e89 100644 --- a/src/Mod/Part/App/OpenCascadeAll.h +++ b/src/Mod/Part/App/OpenCascadeAll.h @@ -303,11 +303,13 @@ #include #include #include -#include #include +#include +#include #include #include #include +#include #include #include #include diff --git a/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp b/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp index b3c63c53a5..0a6f4a18a9 100644 --- a/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp +++ b/src/Mod/Surface/App/Blending/FeatureBlendCurve.cpp @@ -25,17 +25,18 @@ #ifndef _PreComp_ #include #include -#include -#include -#include #include #include #include #endif -#include "FeatureBlendCurve.h" + +#include #include "Mod/Surface/App/Blending/BlendCurve.h" #include "Mod/Surface/App/Blending/BlendPoint.h" +#include "FeatureBlendCurve.h" + + using namespace Surface; const App::PropertyFloatConstraint::Constraints StartParameterConstraint = {0.0, 1.0, 0.05}; diff --git a/src/Mod/Surface/App/CMakeLists.txt b/src/Mod/Surface/App/CMakeLists.txt index 02010eaffe..0fb3e53a95 100644 --- a/src/Mod/Surface/App/CMakeLists.txt +++ b/src/Mod/Surface/App/CMakeLists.txt @@ -48,23 +48,6 @@ SET(Blending_SRCS Blending/BlendCurve.h ) -SET(BlendingPy_SRCS - Blending/BlendPointPy.xml - Blending/BlendPointPyImp.cpp - Blending/BlendCurvePy.xml - Blending/BlendCurvePyImp.cpp -) -SOURCE_GROUP("Blending" FILES ${BlendingPy_SRCS}) - -SET(Blending_SRCS - Blending/FeatureBlendCurve.cpp - Blending/FeatureBlendCurve.h - Blending/BlendPoint.cpp - Blending/BlendPoint.h - Blending/BlendCurve.cpp - Blending/BlendCurve.h -) - SET(Surface_SRCS ${Blending_SRCS} ${BlendingPy_SRCS} @@ -85,6 +68,12 @@ SET(Surface_SRCS FeatureCut.h ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Surface_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(Surface PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + link_directories(${OCC_LIBRARY_DIR}) add_library(Surface SHARED ${Surface_SRCS}) target_link_libraries(Surface ${Surface_LIBS}) diff --git a/src/Mod/Surface/Gui/CMakeLists.txt b/src/Mod/Surface/Gui/CMakeLists.txt index aed56fd113..41e239017b 100644 --- a/src/Mod/Surface/Gui/CMakeLists.txt +++ b/src/Mod/Surface/Gui/CMakeLists.txt @@ -69,6 +69,12 @@ SET(SurfaceGuiIcon_SVG Resources/icons/Surface_Workbench.svg ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${SurfaceGui_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(SurfaceGui PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + link_directories(${OCC_LIBRARY_DIR}) add_library(SurfaceGui SHARED ${SurfaceGui_SRCS} ${SurfaceGuiIcon_SVG}) target_link_libraries(SurfaceGui ${SurfaceGui_LIBS}) diff --git a/src/Mod/Surface/Gui/PreCompiled.h b/src/Mod/Surface/Gui/PreCompiled.h index 423211b18f..0f51743ecf 100644 --- a/src/Mod/Surface/Gui/PreCompiled.h +++ b/src/Mod/Surface/Gui/PreCompiled.h @@ -30,10 +30,6 @@ // STL #include -#ifdef FC_OS_WIN32 -# include -#endif - // Qt #include #include From 91efe220a5db2a1b8ce40b6afb271b6e63e0eeb0 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 03:29:28 +0100 Subject: [PATCH 17/26] [skip ci] [Gui] QtAll.h: whitespace --- src/Gui/QtAll.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/Gui/QtAll.h b/src/Gui/QtAll.h index f2ab5e6382..ae889cd7f3 100644 --- a/src/Gui/QtAll.h +++ b/src/Gui/QtAll.h @@ -20,11 +20,9 @@ * * ***************************************************************************/ - #ifndef __QtAll__ #define __QtAll__ -// Qt Toolkit // QtCore #include #include @@ -58,6 +56,7 @@ #include #include #include + // QtGui #include #include @@ -160,18 +159,22 @@ #include #include #include + // QtNetwork #include #include #include + // QtSvg #include #include + // QtWidgets #include #include #include #include + // QtXML # include # include From 5b7670a449401aca54e035d9f73bf1201aeacb06 Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 03:25:41 +0100 Subject: [PATCH 18/26] [MeshPart] enable precompiled headers - also some sorting --- src/Mod/MeshPart/App/CMakeLists.txt | 6 ++++++ src/Mod/MeshPart/Gui/CMakeLists.txt | 6 ++++++ src/Mod/MeshPart/Gui/CrossSections.cpp | 10 ++++----- src/Mod/MeshPart/Gui/PreCompiled.h | 29 +++++++++++++++++++------- 4 files changed, 39 insertions(+), 12 deletions(-) diff --git a/src/Mod/MeshPart/App/CMakeLists.txt b/src/Mod/MeshPart/App/CMakeLists.txt index a2d579372b..86b6226df0 100644 --- a/src/Mod/MeshPart/App/CMakeLists.txt +++ b/src/Mod/MeshPart/App/CMakeLists.txt @@ -61,6 +61,12 @@ set(MeshPart_Scripts ../Init.py ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MeshPart_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(MeshPart PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + # Suppress -Wundefined-var-template if (MINGW AND CMAKE_COMPILER_IS_CLANGXX) unset(_flag_found CACHE) diff --git a/src/Mod/MeshPart/Gui/CMakeLists.txt b/src/Mod/MeshPart/Gui/CMakeLists.txt index 7ec639184f..9ebb639fc2 100644 --- a/src/Mod/MeshPart/Gui/CMakeLists.txt +++ b/src/Mod/MeshPart/Gui/CMakeLists.txt @@ -72,6 +72,12 @@ set(FLATMESH_PY_SRCS MeshFlatteningCommand.py ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${MeshPartGui_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(MeshPartGui PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + add_library(MeshPartGui SHARED ${MeshPartGui_SRCS} ${MeshPartGui_Scripts} ${FLATMESH_PY_SRCS}) target_link_libraries(MeshPartGui ${MeshPartGui_LIBS}) diff --git a/src/Mod/MeshPart/Gui/CrossSections.cpp b/src/Mod/MeshPart/Gui/CrossSections.cpp index 79ecddba41..94c9dec0ab 100644 --- a/src/Mod/MeshPart/Gui/CrossSections.cpp +++ b/src/Mod/MeshPart/Gui/CrossSections.cpp @@ -42,11 +42,6 @@ # include #endif -#include -#include -#include -#include -#include #include #include #include @@ -55,6 +50,11 @@ #include #include #include +#include +#include +#include +#include +#include #include "CrossSections.h" #include "ui_CrossSections.h" diff --git a/src/Mod/MeshPart/Gui/PreCompiled.h b/src/Mod/MeshPart/Gui/PreCompiled.h index fe28f65378..81142904cf 100644 --- a/src/Mod/MeshPart/Gui/PreCompiled.h +++ b/src/Mod/MeshPart/Gui/PreCompiled.h @@ -37,14 +37,18 @@ #include #include -#ifdef FC_OS_WIN32 -# include -#endif - // Qt Toolkit -#ifndef __QtAll__ -# include -#endif +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include // OCCT #include @@ -62,6 +66,17 @@ #include #include +// Inventor +#include +#include +#include +#include +#include +#include +#include +#include +#include + #endif //_PreComp_ #endif // __PRECOMPILED_GUI__ From af58f804d477a95fee0f2ec6383fb38467b7de1c Mon Sep 17 00:00:00 2001 From: Uwe Date: Thu, 8 Dec 2022 04:16:23 +0100 Subject: [PATCH 19/26] [Points] enable precompiled headers --- src/Mod/Points/App/CMakeLists.txt | 6 ++++++ src/Mod/Points/Gui/CMakeLists.txt | 6 ++++++ src/Mod/Points/Gui/PreCompiled.h | 10 ---------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/Mod/Points/App/CMakeLists.txt b/src/Mod/Points/App/CMakeLists.txt index 5a8c565039..4aa7c9c9ac 100644 --- a/src/Mod/Points/App/CMakeLists.txt +++ b/src/Mod/Points/App/CMakeLists.txt @@ -54,6 +54,12 @@ set(Points_Scripts ../Init.py ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${Points_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(Points PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + add_library(Points SHARED ${Points_SRCS} ${Points_Scripts}) link_directories(${CMAKE_BINARY_DIR}/src/3rdParty/libE57Format) diff --git a/src/Mod/Points/Gui/CMakeLists.txt b/src/Mod/Points/Gui/CMakeLists.txt index 0bbe47b124..5f2572b1c2 100644 --- a/src/Mod/Points/Gui/CMakeLists.txt +++ b/src/Mod/Points/Gui/CMakeLists.txt @@ -54,6 +54,12 @@ SET(PointsGuiIcon_SVG Resources/icons/PointsWorkbench.svg ) +if(FREECAD_USE_PCH) + add_definitions(-D_PreComp_) + GET_MSVC_PRECOMPILED_SOURCE("PreCompiled.cpp" PCH_SRCS ${PointsGui_SRCS}) + ADD_MSVC_PRECOMPILED_HEADER(PointsGui PreCompiled.h PreCompiled.cpp PCH_SRCS) +endif(FREECAD_USE_PCH) + add_library(PointsGui SHARED ${PointsGui_SRCS} ${PointsGui_Scripts} ${PointsGuiIcon_SVG}) target_link_libraries(PointsGui ${PointsGui_LIBS}) diff --git a/src/Mod/Points/Gui/PreCompiled.h b/src/Mod/Points/Gui/PreCompiled.h index 8bfecfb20c..bcfbb39e3c 100644 --- a/src/Mod/Points/Gui/PreCompiled.h +++ b/src/Mod/Points/Gui/PreCompiled.h @@ -25,12 +25,6 @@ #include -#ifdef FC_OS_WIN32 -# ifndef NOMINMAX -# define NOMINMAX -# endif -#endif - #ifdef _PreComp_ // STL @@ -38,10 +32,6 @@ # include # include -#ifdef FC_OS_WIN32 -# include -#endif - // boost # include From 1189be75d044e87cb55c74344405f4e484d57ddc Mon Sep 17 00:00:00 2001 From: Przemo Firszt Date: Fri, 2 Dec 2022 18:44:55 +0000 Subject: [PATCH 20/26] [COPR] fedora: force built-in zipios, disable test --- package/fedora/freecad.spec | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/package/fedora/freecad.spec b/package/fedora/freecad.spec index bdd78c4f0c..5b01193347 100644 --- a/package/fedora/freecad.spec +++ b/package/fedora/freecad.spec @@ -7,7 +7,8 @@ # Maintainers: keep this list of plugins up to date # List plugins in %%{_libdir}/%{name}/lib, less '.so' and 'Gui.so', here -%global plugins Fem FreeCAD Image Import Inspection Mesh MeshPart Part Points QtUnit Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libE57Format libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator +%global plugins Fem FreeCAD PathApp Image Import Inspection Mesh MeshPart Part Points Raytracing ReverseEngineering Robot Sketcher Start Web PartDesignGui _PartDesign Path PathGui Spreadsheet SpreadsheetGui area DraftUtils DraftUtils libDriver libDriverDAT libDriverSTL libDriverUNV libE57Format libMEFISTO2 libSMDS libSMESH libSMESHDS libStdMeshers Measure TechDraw TechDrawGui libarea-native Surface SurfaceGui PathSimulator + # Some configuration options for other environments # rpmbuild --with=bundled_zipios: use bundled version of zipios++ @@ -17,6 +18,9 @@ # rpmbuild --without=bundled_smesh: don't use bundled version of Salome's Mesh %global bundled_smesh %{?_without_bundled_smesh: 0} %{?!_without_bundled_smesh: 1} +#Hack to force zipios +%global bundled_zipios %{?_with_bundled_zipios: 1} %{?!_with_bundled_zipios: 1} + # Prevent RPM from doing its magical 'build' directory for now %global __cmake_in_source_build 0 @@ -67,7 +71,11 @@ BuildRequires: libglvnd-devel BuildRequires: libicu-devel BuildRequires: libkdtree++-devel BuildRequires: libspnav-devel +%if 0%{?fedora} < 37 BuildRequires: libusb-devel +%else +BuildRequires: libusb1-devel +%endif BuildRequires: med-devel BuildRequires: mesa-libEGL-devel BuildRequires: mesa-libGLU-devel @@ -86,6 +94,7 @@ BuildRequires: python3-pycxx-devel %endif BuildRequires: python3-pyside2-devel BuildRequires: python3-shiboken2-devel +BuildRequires: qt5-qtwebengine-devel BuildRequires: qt5-qtwebkit-devel BuildRequires: qt5-qtsvg-devel BuildRequires: qt5-qttools-static @@ -222,6 +231,7 @@ LDFLAGS='-Wl,--as-needed -Wl,--no-undefined'; export LDFLAGS %endif -DPACKAGE_WCREF="%{release} (Git)" \ -DPACKAGE_WCURL="git://github.com/%{github_name}/FreeCAD.git master" \ + -DBUILD_TEST=FALSE \ ../ make fc_version @@ -272,6 +282,9 @@ rm -f %{buildroot}%{_docdir}/%{name}/Start_Page.html #No longer present? #rm -f %{buildroot}%{_docdir}/freecad/ThirdPartyLibraries.html +# Remove header from external library that's erroneously installed +rm -f %{buildroot}%{_libdir}/%{name}/include/E57Format/E57Export.h + # Bug maintainers to keep %%{plugins} macro up to date. # # Make sure there are no plugins that need to be added to plugins macro @@ -329,7 +342,6 @@ fi %{_metainfodir}/* %dir %{_libdir}/%{name} %{_libdir}/%{name}/bin/ -%{_libdir}/%{name}/include/E57Format/E57Export.h %{_libdir}/%{name}/%{_lib}/ %{_libdir}/%{name}/Mod/ %{_libdir}/%{name}/Ext/ From 7b671210e7d4630d4c6e205302fee97f02041ea4 Mon Sep 17 00:00:00 2001 From: luvtofish Date: Tue, 6 Dec 2022 11:58:39 -0600 Subject: [PATCH 21/26] Add files via upload Initial upload --- .../Path/Post/scripts/dynapath_4060_post.py | 621 ++++++++++++++++++ 1 file changed, 621 insertions(+) create mode 100644 src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py new file mode 100644 index 0000000000..d5f185f7f4 --- /dev/null +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -0,0 +1,621 @@ +# *************************************************************************** +# * Copyright (c) 2014 sliptonic * +# * Copyright (c) 2022 luvtofish * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * FreeCAD 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 Lesser General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with FreeCAD; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# * This file has been modified from Sliptonic original Linux CNC post * +# * for use with Dynapath Delta 40M,50M,60M controllers. All changes * +# * and modifications (c) luvtofish (luvtofish@gmail.com) 2022 * +# *************************************************************************** + +from __future__ import print_function +import FreeCAD +from FreeCAD import Units +import Path +import argparse +import datetime +import shlex +import Path.Post.Utils as PostUtils + +TOOLTIP = """ +This is a postprocessor file for the FreeCAD Path workbench. It is used to +take a pseudo-gcode fragment outputted by a Path object, and output +real GCode suitable for Dynapath Delta 40,50, & 60 Controls. It has been written +and tested on FreeCAD Path workbench bundled with FreeCAD v20. +This postprocessor, once placed in the appropriate PathScripts folder, can be +used directly from inside FreeCAD, via the GUI importer or via python scripts with: + +import delta_post +delta_post.export(object,"/path/to/file.ncc","") +""" + +parser = argparse.ArgumentParser(prog="delta_post", add_help=False) +parser.add_argument("--no-header", action="store_true", help="suppress header output") +parser.add_argument( + "--no-comments", action="store_true", help="suppress comment output" +) +parser.add_argument( + "--line-numbers", action="store_true", help="prefix with line numbers" +) +parser.add_argument( + "--no-show-editor", + action="store_true", + help="don't pop up editor before writing output", +) +parser.add_argument( + "--precision", default="3", help="number of digits of precision, default=3" +) +parser.add_argument( + "--preamble", + help='set commands to be issued before the first command, default="G17\nG90\nG80\nG40"', +) +parser.add_argument( + "--postamble", + help='set commands to be issued after the last command, default="M09\nM05\nG80\nG40\nG17\nG90\nM30"', +) +parser.add_argument( + "--inches", action="store_true", help="Convert output for US imperial mode (G70)" +) +parser.add_argument( + "--modal", + action="store_true", + help="Suppress outputting the Same G-command", +) +parser.add_argument( + "--axis-modal", + action="store_true", + help="Suppress outputting identical axis position", +) + +TOOLTIP_ARGS = parser.format_help() + +now = datetime.datetime.now() + +# These globals set common customization preferences +OUTPUT_COMMENTS = True +OUTPUT_HEADER = True +OUTPUT_LINE_NUMBERS = False +SHOW_EDITOR = True +MODAL = False # if true commands are suppressed if the same as previous line. +USE_TLO = False # if true G43 will be output following tool changes +OUTPUT_DOUBLES = ( + True # if false duplicate axis values are suppressed if the same as previous line. +) +COMMAND_SPACE = "" +LINENR = 0 # line number starting value +DWELL_TIME = 1 # Number of seconds to allow spindle to come up to speed. +RETRACT_MODE = False +QCYCLE_RANGE = ( + "G81", + "G82", + "G83", + "G84", + "G85", +) # Quill Cycle range for conditional to enable 2nd reference plane. +SPINDLE_SPEED = 0 +# These globals will be reflected in the Machine configuration of the project +UNITS = "G71" # G71 for metric, G70 for US standard +UNIT_SPEED_FORMAT = "mm/min" +UNIT_FORMAT = "mm" +MACHINE_NAME = "TreeCNC" +CORNER_MIN = {"x": 0, "y": 0, "z": 0} +CORNER_MAX = {"x": 660, "y": 355, "z": 152} +PRECISION = 3 +ABSOLUTE_CIRCLE_CENTER = True +# possible values: +# True use absolute values for the circle center in commands G2, G3 +# False values for I & J are incremental from last point + +# Create Map/ for renaming Fixture Commands from Gxx to Exx +GCODE_MAP = { + "G54": "E01", + "G55": "E02", + "G56": "E03", + "G57": "E04", + "G58": "E05", + "G59": "E06", +} + +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 +G90 +G80 +G40 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G80 +G40 +G17 +G90 +M30 +""" +clearanceHeight = None + +# to distinguish python built-in open function from the one declared below +if open.__module__ in ["__builtin__", "io"]: + pythonopen = open + + +def processArguments(argstring): + global OUTPUT_HEADER + global OUTPUT_COMMENTS + global OUTPUT_LINE_NUMBERS + global SHOW_EDITOR + global PRECISION + global PREAMBLE + global POSTAMBLE + global UNITS + global UNIT_SPEED_FORMAT + global UNIT_FORMAT + global MODAL + global USE_TLO + global OUTPUT_DOUBLES + + try: + args = parser.parse_args(shlex.split(argstring)) + if args.no_header: + OUTPUT_HEADER = False + if args.no_comments: + OUTPUT_COMMENTS = False + if args.line_numbers: + OUTPUT_LINE_NUMBERS = True + if args.no_show_editor: + SHOW_EDITOR = False + print("Show editor = %d" % SHOW_EDITOR) + if args.precision is not None: + PRECISION = args.precision + if args.preamble is not None: + PREAMBLE = args.preamble + if args.postamble is not None: + POSTAMBLE = args.postamble + if args.inches: + UNITS = "G70" + UNIT_SPEED_FORMAT = "in/min" + UNIT_FORMAT = "in" + PRECISION = 3 + if args.modal: + MODAL = True + print("Command duplicates suppressed") + if args.axis_modal: + OUTPUT_DOUBLES = False + print("Doubles suppressed") + + except Exception: + return False + + return True + + +def export(objectslist, filename, argstring): + if not processArguments(argstring): + return None + global UNITS + global UNIT_FORMAT + global UNIT_SPEED_FORMAT + global clearanceHeight + + for obj in objectslist: + if not hasattr(obj, "Path"): + print( + "the object " + + obj.Name + + " is not a path. Please select only path and Compounds." + ) + return None + + print("postprocessing...") + gcode = "" + + # write header + if OUTPUT_HEADER: + gcode += "(%s)\n" % str.upper( + obj.Document.Label[0:8] + ) # Added program name entry and limited to 8 chars. + gcode += linenumber() + "(T)" + "EXPORTED BY FREECAD$\n" + gcode += linenumber() + "(T)" + str.upper("Post Processor: " + __name__) + "$\n" + gcode += linenumber() + "(T)" + str.upper("Output Time:") + str(now) + "$\n" + + # Write the preamble + if OUTPUT_COMMENTS: + gcode += linenumber() + "(T)" + "BEGIN PREAMBLE$\n" + for line in PREAMBLE.splitlines(True): + gcode += linenumber() + line + gcode += linenumber() + UNITS + "\n" + + for obj in objectslist: + + # Skip inactive operations + if hasattr(obj, "Active"): + if not obj.Active: + continue + if hasattr(obj, "Base") and hasattr(obj.Base, "Active"): + if not obj.Base.Active: + continue + if hasattr(obj, "ClearanceHeight"): + clearanceHeight = obj.ClearanceHeight.Value + + # Fix fixture Offset label... + if obj.Label in GCODE_MAP: + obj.Label = GCODE_MAP[obj.Label] + + # do the pre_op + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("begin operation: " + obj.Label) + + "$\n" + ) + gcode += ( + linenumber() + + "(T)" + + str.upper("machine units: ") + + "%s/%s$\n" + % (str.upper(UNIT_SPEED_FORMAT[0:2]), str.upper(UNIT_SPEED_FORMAT[3:6])) + ) + + # get coolant mode + coolantMode = "None" + if ( + hasattr(obj, "CoolantMode") + or hasattr(obj, "Base") + and hasattr(obj.Base, "CoolantMode") + ): + if hasattr(obj, "CoolantMode"): + coolantMode = obj.CoolantMode + else: + coolantMode = obj.Base.CoolantMode + + # turn coolant on if required + if OUTPUT_COMMENTS: + if not coolantMode == "None": + gcode += ( + linenumber() + + "(T)" + + str.upper("Coolant On:" + coolantMode) + + "$\n" + ) + if coolantMode == "Flood": + gcode += linenumber() + "M8" + "\n" + # if coolantMode == "Mist": + # gcode += linenumber() + "M7" + "\n" + + # process the operation gcode + gcode += parse(obj) + + # do the post_op + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("finish operation: " + obj.Label) + + "$\n" + ) + + # turn coolant off if required + if not coolantMode == "None": + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("Coolant Off:" + coolantMode) + + "$\n" + ) + gcode += linenumber() + "M9" + "\n" + + # do the post_amble + if OUTPUT_COMMENTS: + gcode += linenumber() + "(T)" + "BEGIN POSTAMBLE$\n" + for line in POSTAMBLE.splitlines(True): + gcode += linenumber() + line + gcode += "E\n" + + if FreeCAD.GuiUp and SHOW_EDITOR: + dia = PostUtils.GCodeEditorDialog() + dia.editor.setText(gcode) + result = dia.exec_() + if result: + final = dia.editor.toPlainText() + else: + final = gcode + else: + final = gcode + + print("done postprocessing.") + + if not filename == "-": + gfile = pythonopen(filename, "w") + gfile.write(final) + gfile.close() + + return final + + +def linenumber(): + global LINENR + if OUTPUT_LINE_NUMBERS is True: + LINENR += 1 + return "N" + "%04d" % ( + LINENR + ) # + " " # Added formating for 4 digit line number. + return "" + + +def parse(pathobj): + global PRECISION + global MODAL + global OUTPUT_DOUBLES + global UNIT_FORMAT + global UNIT_SPEED_FORMAT + global RETRACT_MODE + global DWELL_TIME + global clearanceHeight + + lastX = 0 + lastY = 0 + lastZ = 0 + out = "" + lastcommand = None + precision_string = "." + str(PRECISION) + "f" + currLocation = {} # keep track for no doubles + + # the order of parameters + # params = ['X','Y','Z','A','B','I','J','K','F','S'] #This list control the order of parameters + params = [ + "X", + "Y", + "Z", + "A", + "B", + "C", + "I", + "J", + "F", + "S", + "T", + "Q", + "R", + "L", + "K", + "P", + "O", + ] + + firstmove = Path.Command("G0", {"X": -1, "Y": -1, "Z": -1, "F": 0.0}) + currLocation.update(firstmove.Parameters) # set first location parameters + + if hasattr(pathobj, "Group"): # We have a compound or project. + if OUTPUT_COMMENTS: + out += ( + linenumber() + "(T)" + str.upper("compound: " + pathobj.Label) + "$\n" + ) + for p in pathobj.Group: + out += parse(p) + return out + else: # parsing simple path + + # groups might contain non-path things like stock. + if not hasattr(pathobj, "Path"): + return out + + for c in pathobj.Path.Commands: + outstring = [] + command = c.Name + # Convert G54-G59 Fixture offsets to E01-E06 for Dynapath Delta Control + if command in GCODE_MAP: + command = GCODE_MAP[command] + + if command.startswith("("): + if OUTPUT_COMMENTS: + command = "(T)" + str.upper(command) + "$" + + outstring.append(command) + + # if modal: suppress the command if it is the same as the last one + if MODAL is True: + if command == lastcommand: + outstring.pop(0) + + if c.Name[0] == "(" and not OUTPUT_COMMENTS: # command is a comment + continue + + # Now add the remaining parameters in order + for param in params: + if param in c.Parameters: + if param == "F" and ( + currLocation[param] != c.Parameters[param] or OUTPUT_DOUBLES + ): + if c.Name not in [ + "G0", + "G00", + ]: + speed = Units.Quantity( + c.Parameters["F"], FreeCAD.Units.Velocity + ) + if speed.getValueAs(UNIT_SPEED_FORMAT) > 0.0: + outstring.append( + param + + format( + float(speed.getValueAs(UNIT_SPEED_FORMAT)), + precision_string, + ) + ) + else: + continue + elif param == "Z" and ( + c.Parameters["Z"] == clearanceHeight + and c.Parameters["Z"] != lastZ + ): + x = 0 + y = 0 + outstring.insert( + 1, + "X" + + PostUtils.fmt(x, PRECISION, UNITS) + + "Y" + + PostUtils.fmt(y, PRECISION, UNITS), + ) + outstring.append( + param + PostUtils.fmt(c.Parameters["Z"], PRECISION, UNITS) + ) + elif param == "X" and (command in QCYCLE_RANGE): + pos = Units.Quantity(c.Parameters["X"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + elif param == "Y" and (command in QCYCLE_RANGE): + pos = Units.Quantity(c.Parameters["Y"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + # Remove X and Y betwen QCYCLE's since we already included them. + elif lastcommand in QCYCLE_RANGE and (param == "X" or "Y"): + outstring = [] + elif param == "S": + SPINDLE_SPEED = c.Parameters["S"] + outstring.append( + param + "{:.0f}".format(c.Parameters["S"]) + ) # Added formating to strip trailing .000 from RPM + elif param == "T": + outstring.append( + param + "{:.0f}".format(c.Parameters["T"]) + ) # Added formating to strip trailing .000 from Tool number + elif param == "I" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in I and J + i = c.Parameters["I"] + if ABSOLUTE_CIRCLE_CENTER: + i += lastX + outstring.append(param + PostUtils.fmt(i, PRECISION, UNITS)) + elif param == "J" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in I and J + j = c.Parameters["J"] + if ABSOLUTE_CIRCLE_CENTER: + j += lastY + outstring.append(param + PostUtils.fmt(j, PRECISION, UNITS)) + elif param == "K" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in K (Z axis arc) + k = c.Parameters["K"] + if ABSOLUTE_CIRCLE_CENTER: + k += lastZ + if command == ("G18" or "G19"): + outstring.append( + param + PostUtils.fmt(k, PRECISION, UNITS) + ) + elif param == "Q": + pos = Units.Quantity(c.Parameters["Q"], FreeCAD.Units.Length) + outstring.append( + "K" + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + elif (param == "R") and ((command in QCYCLE_RANGE)): + pos = Units.Quantity( + pathobj.ClearanceHeight.Value, FreeCAD.Units.Length + ) + outstring.insert( + 6, + "O" + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ), + ) # Insert "O" param for 2nd reference plane (Clearance Height) + pos = Units.Quantity(c.Parameters["R"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) # First Reference plan (Safe Height) + elif param == "P": + outstring.append( + "L" + format(c.Parameters[param], precision_string) + ) + else: + if ( + (not OUTPUT_DOUBLES) + and (param in currLocation) + and (currLocation[param] == c.Parameters[param]) + ): + continue + else: + pos = Units.Quantity( + c.Parameters[param], FreeCAD.Units.Length + ) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + + # save the last X, Y values + if "X" in c.Parameters: + lastX = c.Parameters["X"] + if "Y" in c.Parameters: + lastY = c.Parameters["Y"] + if "Z" in c.Parameters: + lastZ = c.Parameters["Z"] + + # store the latest command + lastcommand = command + currLocation.update(c.Parameters) + + # Check for Tool Change: + if command == "M6": + if OUTPUT_COMMENTS: + out += linenumber() + "(T)" + "BEGIN TOOLCHANGE$\n" + + if command == "message": + if OUTPUT_COMMENTS is False: + out = [] + else: + outstring.pop(0) # remove the command + # G98 is not used by dynapath and G99 is not used in Drilling/Boring/Tapping. + if c.Name == "G98" or (c.Name == "G99" and pathobj.Label == "Drilling"): + outstring = [] + + # prepend a line number and append a newline + if len(outstring) >= 1: + if OUTPUT_LINE_NUMBERS: + outstring.insert(0, (linenumber())) + + # append the line to the final output + for w in outstring: + out += w.strip() + COMMAND_SPACE + out += "\n" + + # Add a DWELL after spindle start based on RPM. + if DWELL_TIME > 0.0: + if command in ["M3", "M03", "M4", "M04"]: + DWELL_TIME = (SPINDLE_SPEED / 100) / 10 + out += linenumber() + "L%.1f\n" % DWELL_TIME + + return out + +print(__name__ + " gcode postprocessor loaded.") From 4342251c4422f6f5ff91412cb4adfd4d74ee7178 Mon Sep 17 00:00:00 2001 From: luvtofish Date: Tue, 6 Dec 2022 15:05:52 -0600 Subject: [PATCH 22/26] Add files via upload Fixed format string on print statement. --- src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py index d5f185f7f4..66b9cda060 100644 --- a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -180,7 +180,7 @@ def processArguments(argstring): OUTPUT_LINE_NUMBERS = True if args.no_show_editor: SHOW_EDITOR = False - print("Show editor = %d" % SHOW_EDITOR) + print("Show editor = %r" % (SHOW_EDITOR)) if args.precision is not None: PRECISION = args.precision if args.preamble is not None: From 5553b6ca9c8720c26ef0f3c1cb80430b82954d23 Mon Sep 17 00:00:00 2001 From: luvtofish Date: Wed, 7 Dec 2022 10:19:24 -0600 Subject: [PATCH 23/26] Removed TLO since not used. --- .../Path/Post/scripts/dynapath_4060_post.py | 1240 ++++++++--------- 1 file changed, 619 insertions(+), 621 deletions(-) diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py index 66b9cda060..ef4b864736 100644 --- a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -1,621 +1,619 @@ -# *************************************************************************** -# * Copyright (c) 2014 sliptonic * -# * Copyright (c) 2022 luvtofish * -# * * -# * This file is part of the FreeCAD CAx development system. * -# * * -# * This program is free software; you can redistribute it and/or modify * -# * it under the terms of the GNU Lesser General Public License (LGPL) * -# * as published by the Free Software Foundation; either version 2 of * -# * the License, or (at your option) any later version. * -# * for detail see the LICENCE text file. * -# * * -# * FreeCAD 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 Lesser General Public License for more details. * -# * * -# * You should have received a copy of the GNU Library General Public * -# * License along with FreeCAD; if not, write to the Free Software * -# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * -# * USA * -# * * -# * This file has been modified from Sliptonic original Linux CNC post * -# * for use with Dynapath Delta 40M,50M,60M controllers. All changes * -# * and modifications (c) luvtofish (luvtofish@gmail.com) 2022 * -# *************************************************************************** - -from __future__ import print_function -import FreeCAD -from FreeCAD import Units -import Path -import argparse -import datetime -import shlex -import Path.Post.Utils as PostUtils - -TOOLTIP = """ -This is a postprocessor file for the FreeCAD Path workbench. It is used to -take a pseudo-gcode fragment outputted by a Path object, and output -real GCode suitable for Dynapath Delta 40,50, & 60 Controls. It has been written -and tested on FreeCAD Path workbench bundled with FreeCAD v20. -This postprocessor, once placed in the appropriate PathScripts folder, can be -used directly from inside FreeCAD, via the GUI importer or via python scripts with: - -import delta_post -delta_post.export(object,"/path/to/file.ncc","") -""" - -parser = argparse.ArgumentParser(prog="delta_post", add_help=False) -parser.add_argument("--no-header", action="store_true", help="suppress header output") -parser.add_argument( - "--no-comments", action="store_true", help="suppress comment output" -) -parser.add_argument( - "--line-numbers", action="store_true", help="prefix with line numbers" -) -parser.add_argument( - "--no-show-editor", - action="store_true", - help="don't pop up editor before writing output", -) -parser.add_argument( - "--precision", default="3", help="number of digits of precision, default=3" -) -parser.add_argument( - "--preamble", - help='set commands to be issued before the first command, default="G17\nG90\nG80\nG40"', -) -parser.add_argument( - "--postamble", - help='set commands to be issued after the last command, default="M09\nM05\nG80\nG40\nG17\nG90\nM30"', -) -parser.add_argument( - "--inches", action="store_true", help="Convert output for US imperial mode (G70)" -) -parser.add_argument( - "--modal", - action="store_true", - help="Suppress outputting the Same G-command", -) -parser.add_argument( - "--axis-modal", - action="store_true", - help="Suppress outputting identical axis position", -) - -TOOLTIP_ARGS = parser.format_help() - -now = datetime.datetime.now() - -# These globals set common customization preferences -OUTPUT_COMMENTS = True -OUTPUT_HEADER = True -OUTPUT_LINE_NUMBERS = False -SHOW_EDITOR = True -MODAL = False # if true commands are suppressed if the same as previous line. -USE_TLO = False # if true G43 will be output following tool changes -OUTPUT_DOUBLES = ( - True # if false duplicate axis values are suppressed if the same as previous line. -) -COMMAND_SPACE = "" -LINENR = 0 # line number starting value -DWELL_TIME = 1 # Number of seconds to allow spindle to come up to speed. -RETRACT_MODE = False -QCYCLE_RANGE = ( - "G81", - "G82", - "G83", - "G84", - "G85", -) # Quill Cycle range for conditional to enable 2nd reference plane. -SPINDLE_SPEED = 0 -# These globals will be reflected in the Machine configuration of the project -UNITS = "G71" # G71 for metric, G70 for US standard -UNIT_SPEED_FORMAT = "mm/min" -UNIT_FORMAT = "mm" -MACHINE_NAME = "TreeCNC" -CORNER_MIN = {"x": 0, "y": 0, "z": 0} -CORNER_MAX = {"x": 660, "y": 355, "z": 152} -PRECISION = 3 -ABSOLUTE_CIRCLE_CENTER = True -# possible values: -# True use absolute values for the circle center in commands G2, G3 -# False values for I & J are incremental from last point - -# Create Map/ for renaming Fixture Commands from Gxx to Exx -GCODE_MAP = { - "G54": "E01", - "G55": "E02", - "G56": "E03", - "G57": "E04", - "G58": "E05", - "G59": "E06", -} - -# Preamble text will appear at the beginning of the GCODE output file. -PREAMBLE = """G17 -G90 -G80 -G40 -""" - -# Postamble text will appear following the last operation. -POSTAMBLE = """M05 -G80 -G40 -G17 -G90 -M30 -""" -clearanceHeight = None - -# to distinguish python built-in open function from the one declared below -if open.__module__ in ["__builtin__", "io"]: - pythonopen = open - - -def processArguments(argstring): - global OUTPUT_HEADER - global OUTPUT_COMMENTS - global OUTPUT_LINE_NUMBERS - global SHOW_EDITOR - global PRECISION - global PREAMBLE - global POSTAMBLE - global UNITS - global UNIT_SPEED_FORMAT - global UNIT_FORMAT - global MODAL - global USE_TLO - global OUTPUT_DOUBLES - - try: - args = parser.parse_args(shlex.split(argstring)) - if args.no_header: - OUTPUT_HEADER = False - if args.no_comments: - OUTPUT_COMMENTS = False - if args.line_numbers: - OUTPUT_LINE_NUMBERS = True - if args.no_show_editor: - SHOW_EDITOR = False - print("Show editor = %r" % (SHOW_EDITOR)) - if args.precision is not None: - PRECISION = args.precision - if args.preamble is not None: - PREAMBLE = args.preamble - if args.postamble is not None: - POSTAMBLE = args.postamble - if args.inches: - UNITS = "G70" - UNIT_SPEED_FORMAT = "in/min" - UNIT_FORMAT = "in" - PRECISION = 3 - if args.modal: - MODAL = True - print("Command duplicates suppressed") - if args.axis_modal: - OUTPUT_DOUBLES = False - print("Doubles suppressed") - - except Exception: - return False - - return True - - -def export(objectslist, filename, argstring): - if not processArguments(argstring): - return None - global UNITS - global UNIT_FORMAT - global UNIT_SPEED_FORMAT - global clearanceHeight - - for obj in objectslist: - if not hasattr(obj, "Path"): - print( - "the object " - + obj.Name - + " is not a path. Please select only path and Compounds." - ) - return None - - print("postprocessing...") - gcode = "" - - # write header - if OUTPUT_HEADER: - gcode += "(%s)\n" % str.upper( - obj.Document.Label[0:8] - ) # Added program name entry and limited to 8 chars. - gcode += linenumber() + "(T)" + "EXPORTED BY FREECAD$\n" - gcode += linenumber() + "(T)" + str.upper("Post Processor: " + __name__) + "$\n" - gcode += linenumber() + "(T)" + str.upper("Output Time:") + str(now) + "$\n" - - # Write the preamble - if OUTPUT_COMMENTS: - gcode += linenumber() + "(T)" + "BEGIN PREAMBLE$\n" - for line in PREAMBLE.splitlines(True): - gcode += linenumber() + line - gcode += linenumber() + UNITS + "\n" - - for obj in objectslist: - - # Skip inactive operations - if hasattr(obj, "Active"): - if not obj.Active: - continue - if hasattr(obj, "Base") and hasattr(obj.Base, "Active"): - if not obj.Base.Active: - continue - if hasattr(obj, "ClearanceHeight"): - clearanceHeight = obj.ClearanceHeight.Value - - # Fix fixture Offset label... - if obj.Label in GCODE_MAP: - obj.Label = GCODE_MAP[obj.Label] - - # do the pre_op - if OUTPUT_COMMENTS: - gcode += ( - linenumber() - + "(T)" - + str.upper("begin operation: " + obj.Label) - + "$\n" - ) - gcode += ( - linenumber() - + "(T)" - + str.upper("machine units: ") - + "%s/%s$\n" - % (str.upper(UNIT_SPEED_FORMAT[0:2]), str.upper(UNIT_SPEED_FORMAT[3:6])) - ) - - # get coolant mode - coolantMode = "None" - if ( - hasattr(obj, "CoolantMode") - or hasattr(obj, "Base") - and hasattr(obj.Base, "CoolantMode") - ): - if hasattr(obj, "CoolantMode"): - coolantMode = obj.CoolantMode - else: - coolantMode = obj.Base.CoolantMode - - # turn coolant on if required - if OUTPUT_COMMENTS: - if not coolantMode == "None": - gcode += ( - linenumber() - + "(T)" - + str.upper("Coolant On:" + coolantMode) - + "$\n" - ) - if coolantMode == "Flood": - gcode += linenumber() + "M8" + "\n" - # if coolantMode == "Mist": - # gcode += linenumber() + "M7" + "\n" - - # process the operation gcode - gcode += parse(obj) - - # do the post_op - if OUTPUT_COMMENTS: - gcode += ( - linenumber() - + "(T)" - + str.upper("finish operation: " + obj.Label) - + "$\n" - ) - - # turn coolant off if required - if not coolantMode == "None": - if OUTPUT_COMMENTS: - gcode += ( - linenumber() - + "(T)" - + str.upper("Coolant Off:" + coolantMode) - + "$\n" - ) - gcode += linenumber() + "M9" + "\n" - - # do the post_amble - if OUTPUT_COMMENTS: - gcode += linenumber() + "(T)" + "BEGIN POSTAMBLE$\n" - for line in POSTAMBLE.splitlines(True): - gcode += linenumber() + line - gcode += "E\n" - - if FreeCAD.GuiUp and SHOW_EDITOR: - dia = PostUtils.GCodeEditorDialog() - dia.editor.setText(gcode) - result = dia.exec_() - if result: - final = dia.editor.toPlainText() - else: - final = gcode - else: - final = gcode - - print("done postprocessing.") - - if not filename == "-": - gfile = pythonopen(filename, "w") - gfile.write(final) - gfile.close() - - return final - - -def linenumber(): - global LINENR - if OUTPUT_LINE_NUMBERS is True: - LINENR += 1 - return "N" + "%04d" % ( - LINENR - ) # + " " # Added formating for 4 digit line number. - return "" - - -def parse(pathobj): - global PRECISION - global MODAL - global OUTPUT_DOUBLES - global UNIT_FORMAT - global UNIT_SPEED_FORMAT - global RETRACT_MODE - global DWELL_TIME - global clearanceHeight - - lastX = 0 - lastY = 0 - lastZ = 0 - out = "" - lastcommand = None - precision_string = "." + str(PRECISION) + "f" - currLocation = {} # keep track for no doubles - - # the order of parameters - # params = ['X','Y','Z','A','B','I','J','K','F','S'] #This list control the order of parameters - params = [ - "X", - "Y", - "Z", - "A", - "B", - "C", - "I", - "J", - "F", - "S", - "T", - "Q", - "R", - "L", - "K", - "P", - "O", - ] - - firstmove = Path.Command("G0", {"X": -1, "Y": -1, "Z": -1, "F": 0.0}) - currLocation.update(firstmove.Parameters) # set first location parameters - - if hasattr(pathobj, "Group"): # We have a compound or project. - if OUTPUT_COMMENTS: - out += ( - linenumber() + "(T)" + str.upper("compound: " + pathobj.Label) + "$\n" - ) - for p in pathobj.Group: - out += parse(p) - return out - else: # parsing simple path - - # groups might contain non-path things like stock. - if not hasattr(pathobj, "Path"): - return out - - for c in pathobj.Path.Commands: - outstring = [] - command = c.Name - # Convert G54-G59 Fixture offsets to E01-E06 for Dynapath Delta Control - if command in GCODE_MAP: - command = GCODE_MAP[command] - - if command.startswith("("): - if OUTPUT_COMMENTS: - command = "(T)" + str.upper(command) + "$" - - outstring.append(command) - - # if modal: suppress the command if it is the same as the last one - if MODAL is True: - if command == lastcommand: - outstring.pop(0) - - if c.Name[0] == "(" and not OUTPUT_COMMENTS: # command is a comment - continue - - # Now add the remaining parameters in order - for param in params: - if param in c.Parameters: - if param == "F" and ( - currLocation[param] != c.Parameters[param] or OUTPUT_DOUBLES - ): - if c.Name not in [ - "G0", - "G00", - ]: - speed = Units.Quantity( - c.Parameters["F"], FreeCAD.Units.Velocity - ) - if speed.getValueAs(UNIT_SPEED_FORMAT) > 0.0: - outstring.append( - param - + format( - float(speed.getValueAs(UNIT_SPEED_FORMAT)), - precision_string, - ) - ) - else: - continue - elif param == "Z" and ( - c.Parameters["Z"] == clearanceHeight - and c.Parameters["Z"] != lastZ - ): - x = 0 - y = 0 - outstring.insert( - 1, - "X" - + PostUtils.fmt(x, PRECISION, UNITS) - + "Y" - + PostUtils.fmt(y, PRECISION, UNITS), - ) - outstring.append( - param + PostUtils.fmt(c.Parameters["Z"], PRECISION, UNITS) - ) - elif param == "X" and (command in QCYCLE_RANGE): - pos = Units.Quantity(c.Parameters["X"], FreeCAD.Units.Length) - outstring.append( - param - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ) - ) - elif param == "Y" and (command in QCYCLE_RANGE): - pos = Units.Quantity(c.Parameters["Y"], FreeCAD.Units.Length) - outstring.append( - param - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ) - ) - # Remove X and Y betwen QCYCLE's since we already included them. - elif lastcommand in QCYCLE_RANGE and (param == "X" or "Y"): - outstring = [] - elif param == "S": - SPINDLE_SPEED = c.Parameters["S"] - outstring.append( - param + "{:.0f}".format(c.Parameters["S"]) - ) # Added formating to strip trailing .000 from RPM - elif param == "T": - outstring.append( - param + "{:.0f}".format(c.Parameters["T"]) - ) # Added formating to strip trailing .000 from Tool number - elif param == "I" and (command == "G2" or command == "G3"): - # Convert incremental arc center to absolute in I and J - i = c.Parameters["I"] - if ABSOLUTE_CIRCLE_CENTER: - i += lastX - outstring.append(param + PostUtils.fmt(i, PRECISION, UNITS)) - elif param == "J" and (command == "G2" or command == "G3"): - # Convert incremental arc center to absolute in I and J - j = c.Parameters["J"] - if ABSOLUTE_CIRCLE_CENTER: - j += lastY - outstring.append(param + PostUtils.fmt(j, PRECISION, UNITS)) - elif param == "K" and (command == "G2" or command == "G3"): - # Convert incremental arc center to absolute in K (Z axis arc) - k = c.Parameters["K"] - if ABSOLUTE_CIRCLE_CENTER: - k += lastZ - if command == ("G18" or "G19"): - outstring.append( - param + PostUtils.fmt(k, PRECISION, UNITS) - ) - elif param == "Q": - pos = Units.Quantity(c.Parameters["Q"], FreeCAD.Units.Length) - outstring.append( - "K" - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ) - ) - elif (param == "R") and ((command in QCYCLE_RANGE)): - pos = Units.Quantity( - pathobj.ClearanceHeight.Value, FreeCAD.Units.Length - ) - outstring.insert( - 6, - "O" - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ), - ) # Insert "O" param for 2nd reference plane (Clearance Height) - pos = Units.Quantity(c.Parameters["R"], FreeCAD.Units.Length) - outstring.append( - param - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ) - ) # First Reference plan (Safe Height) - elif param == "P": - outstring.append( - "L" + format(c.Parameters[param], precision_string) - ) - else: - if ( - (not OUTPUT_DOUBLES) - and (param in currLocation) - and (currLocation[param] == c.Parameters[param]) - ): - continue - else: - pos = Units.Quantity( - c.Parameters[param], FreeCAD.Units.Length - ) - outstring.append( - param - + format( - float(pos.getValueAs(UNIT_FORMAT)), precision_string - ) - ) - - # save the last X, Y values - if "X" in c.Parameters: - lastX = c.Parameters["X"] - if "Y" in c.Parameters: - lastY = c.Parameters["Y"] - if "Z" in c.Parameters: - lastZ = c.Parameters["Z"] - - # store the latest command - lastcommand = command - currLocation.update(c.Parameters) - - # Check for Tool Change: - if command == "M6": - if OUTPUT_COMMENTS: - out += linenumber() + "(T)" + "BEGIN TOOLCHANGE$\n" - - if command == "message": - if OUTPUT_COMMENTS is False: - out = [] - else: - outstring.pop(0) # remove the command - # G98 is not used by dynapath and G99 is not used in Drilling/Boring/Tapping. - if c.Name == "G98" or (c.Name == "G99" and pathobj.Label == "Drilling"): - outstring = [] - - # prepend a line number and append a newline - if len(outstring) >= 1: - if OUTPUT_LINE_NUMBERS: - outstring.insert(0, (linenumber())) - - # append the line to the final output - for w in outstring: - out += w.strip() + COMMAND_SPACE - out += "\n" - - # Add a DWELL after spindle start based on RPM. - if DWELL_TIME > 0.0: - if command in ["M3", "M03", "M4", "M04"]: - DWELL_TIME = (SPINDLE_SPEED / 100) / 10 - out += linenumber() + "L%.1f\n" % DWELL_TIME - - return out - -print(__name__ + " gcode postprocessor loaded.") +# *************************************************************************** +# * Copyright (c) 2014 sliptonic * +# * Copyright (c) 2022 luvtofish * +# * * +# * This file is part of the FreeCAD CAx development system. * +# * * +# * This program is free software; you can redistribute it and/or modify * +# * it under the terms of the GNU Lesser General Public License (LGPL) * +# * as published by the Free Software Foundation; either version 2 of * +# * the License, or (at your option) any later version. * +# * for detail see the LICENCE text file. * +# * * +# * FreeCAD 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 Lesser General Public License for more details. * +# * * +# * You should have received a copy of the GNU Library General Public * +# * License along with FreeCAD; if not, write to the Free Software * +# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * +# * USA * +# * * +# * This file has been modified from Sliptonic original Linux CNC post * +# * for use with Dynapath Delta 40M,50M,60M controllers. All changes * +# * and modifications (c) luvtofish (luvtofish@gmail.com) 2022 * +# *************************************************************************** + +from __future__ import print_function +import FreeCAD +from FreeCAD import Units +import Path +import argparse +import datetime +import shlex +import Path.Post.Utils as PostUtils + +TOOLTIP = """ +This is a postprocessor file for the FreeCAD Path workbench. It is used to +take a pseudo-gcode fragment outputted by a Path object, and output +real GCode suitable for Dynapath Delta 40,50, & 60 Controls. It has been written +and tested on FreeCAD Path workbench bundled with FreeCAD v20. +This postprocessor, once placed in the appropriate PathScripts folder, can be +used directly from inside FreeCAD, via the GUI importer or via python scripts with: + +import delta_post +delta_post.export(object,"/path/to/file.ncc","") +""" + +parser = argparse.ArgumentParser(prog="delta_post", add_help=False) +parser.add_argument("--no-header", action="store_true", help="suppress header output") +parser.add_argument( + "--no-comments", action="store_true", help="suppress comment output" +) +parser.add_argument( + "--line-numbers", action="store_true", help="prefix with line numbers" +) +parser.add_argument( + "--no-show-editor", + action="store_true", + help="don't pop up editor before writing output", +) +parser.add_argument( + "--precision", default="3", help="number of digits of precision, default=3" +) +parser.add_argument( + "--preamble", + help='set commands to be issued before the first command, default="G17\nG90\nG80\nG40"', +) +parser.add_argument( + "--postamble", + help='set commands to be issued after the last command, default="M09\nM05\nG80\nG40\nG17\nG90\nM30"', +) +parser.add_argument( + "--inches", action="store_true", help="Convert output for US imperial mode (G70)" +) +parser.add_argument( + "--modal", + action="store_true", + help="Suppress outputting the Same G-command", +) +parser.add_argument( + "--axis-modal", + action="store_true", + help="Suppress outputting identical axis position", +) + +TOOLTIP_ARGS = parser.format_help() + +now = datetime.datetime.now() + +# These globals set common customization preferences +OUTPUT_COMMENTS = True +OUTPUT_HEADER = True +OUTPUT_LINE_NUMBERS = False +SHOW_EDITOR = True +MODAL = False # if true commands are suppressed if the same as previous line. +OUTPUT_DOUBLES = ( + True # if false duplicate axis values are suppressed if the same as previous line. +) +COMMAND_SPACE = "" +LINENR = 0 # line number starting value +DWELL_TIME = 1 # Number of seconds to allow spindle to come up to speed. +RETRACT_MODE = False +QCYCLE_RANGE = ( + "G81", + "G82", + "G83", + "G84", + "G85", +) # Quill Cycle range for conditional to enable 2nd reference plane. +SPINDLE_SPEED = 0 +# These globals will be reflected in the Machine configuration of the project +UNITS = "G71" # G71 for metric, G70 for US standard +UNIT_SPEED_FORMAT = "mm/min" +UNIT_FORMAT = "mm" +MACHINE_NAME = "TreeCNC" +CORNER_MIN = {"x": 0, "y": 0, "z": 0} +CORNER_MAX = {"x": 660, "y": 355, "z": 152} +PRECISION = 3 +ABSOLUTE_CIRCLE_CENTER = True +# possible values: +# True use absolute values for the circle center in commands G2, G3 +# False values for I & J are incremental from last point + +# Create Map/ for renaming Fixture Commands from Gxx to Exx +GCODE_MAP = { + "G54": "E01", + "G55": "E02", + "G56": "E03", + "G57": "E04", + "G58": "E05", + "G59": "E06", +} + +# Preamble text will appear at the beginning of the GCODE output file. +PREAMBLE = """G17 +G90 +G80 +G40 +""" + +# Postamble text will appear following the last operation. +POSTAMBLE = """M05 +G80 +G40 +G17 +G90 +M30 +""" +clearanceHeight = None + +# to distinguish python built-in open function from the one declared below +if open.__module__ in ["__builtin__", "io"]: + pythonopen = open + + +def processArguments(argstring): + global OUTPUT_HEADER + global OUTPUT_COMMENTS + global OUTPUT_LINE_NUMBERS + global SHOW_EDITOR + global PRECISION + global PREAMBLE + global POSTAMBLE + global UNITS + global UNIT_SPEED_FORMAT + global UNIT_FORMAT + global MODAL + global OUTPUT_DOUBLES + + try: + args = parser.parse_args(shlex.split(argstring)) + if args.no_header: + OUTPUT_HEADER = False + if args.no_comments: + OUTPUT_COMMENTS = False + if args.line_numbers: + OUTPUT_LINE_NUMBERS = True + if args.no_show_editor: + SHOW_EDITOR = False + print("Show editor = %r" % (SHOW_EDITOR)) + if args.precision is not None: + PRECISION = args.precision + if args.preamble is not None: + PREAMBLE = args.preamble + if args.postamble is not None: + POSTAMBLE = args.postamble + if args.inches: + UNITS = "G70" + UNIT_SPEED_FORMAT = "in/min" + UNIT_FORMAT = "in" + PRECISION = 3 + if args.modal: + MODAL = True + print("Command duplicates suppressed") + if args.axis_modal: + OUTPUT_DOUBLES = False + print("Doubles suppressed") + + except Exception: + return False + + return True + + +def export(objectslist, filename, argstring): + if not processArguments(argstring): + return None + global UNITS + global UNIT_FORMAT + global UNIT_SPEED_FORMAT + global clearanceHeight + + for obj in objectslist: + if not hasattr(obj, "Path"): + print( + "the object " + + obj.Name + + " is not a path. Please select only path and Compounds." + ) + return None + + print("postprocessing...") + gcode = "" + + # write header + if OUTPUT_HEADER: + gcode += "(%s)\n" % str.upper( + obj.Document.Label[0:8] + ) # Added program name entry and limited to 8 chars. + gcode += linenumber() + "(T)" + "EXPORTED BY FREECAD$\n" + gcode += linenumber() + "(T)" + str.upper("Post Processor: " + __name__) + "$\n" + gcode += linenumber() + "(T)" + str.upper("Output Time:") + str(now) + "$\n" + + # Write the preamble + if OUTPUT_COMMENTS: + gcode += linenumber() + "(T)" + "BEGIN PREAMBLE$\n" + for line in PREAMBLE.splitlines(True): + gcode += linenumber() + line + gcode += linenumber() + UNITS + "\n" + + for obj in objectslist: + + # Skip inactive operations + if hasattr(obj, "Active"): + if not obj.Active: + continue + if hasattr(obj, "Base") and hasattr(obj.Base, "Active"): + if not obj.Base.Active: + continue + if hasattr(obj, "ClearanceHeight"): + clearanceHeight = obj.ClearanceHeight.Value + + # Fix fixture Offset label... + if obj.Label in GCODE_MAP: + obj.Label = GCODE_MAP[obj.Label] + + # do the pre_op + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("begin operation: " + obj.Label) + + "$\n" + ) + gcode += ( + linenumber() + + "(T)" + + str.upper("machine units: ") + + "%s/%s$\n" + % (str.upper(UNIT_SPEED_FORMAT[0:2]), str.upper(UNIT_SPEED_FORMAT[3:6])) + ) + + # get coolant mode + coolantMode = "None" + if ( + hasattr(obj, "CoolantMode") + or hasattr(obj, "Base") + and hasattr(obj.Base, "CoolantMode") + ): + if hasattr(obj, "CoolantMode"): + coolantMode = obj.CoolantMode + else: + coolantMode = obj.Base.CoolantMode + + # turn coolant on if required + if OUTPUT_COMMENTS: + if not coolantMode == "None": + gcode += ( + linenumber() + + "(T)" + + str.upper("Coolant On:" + coolantMode) + + "$\n" + ) + if coolantMode == "Flood": + gcode += linenumber() + "M8" + "\n" + # if coolantMode == "Mist": + # gcode += linenumber() + "M7" + "\n" + + # process the operation gcode + gcode += parse(obj) + + # do the post_op + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("finish operation: " + obj.Label) + + "$\n" + ) + + # turn coolant off if required + if not coolantMode == "None": + if OUTPUT_COMMENTS: + gcode += ( + linenumber() + + "(T)" + + str.upper("Coolant Off:" + coolantMode) + + "$\n" + ) + gcode += linenumber() + "M9" + "\n" + + # do the post_amble + if OUTPUT_COMMENTS: + gcode += linenumber() + "(T)" + "BEGIN POSTAMBLE$\n" + for line in POSTAMBLE.splitlines(True): + gcode += linenumber() + line + gcode += "E\n" + + if FreeCAD.GuiUp and SHOW_EDITOR: + dia = PostUtils.GCodeEditorDialog() + dia.editor.setText(gcode) + result = dia.exec_() + if result: + final = dia.editor.toPlainText() + else: + final = gcode + else: + final = gcode + + print("done postprocessing.") + + if not filename == "-": + gfile = pythonopen(filename, "w") + gfile.write(final) + gfile.close() + + return final + + +def linenumber(): + global LINENR + if OUTPUT_LINE_NUMBERS is True: + LINENR += 1 + return "N" + "%04d" % ( + LINENR + ) # + " " # Added formating for 4 digit line number. + return "" + + +def parse(pathobj): + global PRECISION + global MODAL + global OUTPUT_DOUBLES + global UNIT_FORMAT + global UNIT_SPEED_FORMAT + global RETRACT_MODE + global DWELL_TIME + global clearanceHeight + + lastX = 0 + lastY = 0 + lastZ = 0 + out = "" + lastcommand = None + precision_string = "." + str(PRECISION) + "f" + currLocation = {} # keep track for no doubles + + # the order of parameters + # params = ['X','Y','Z','A','B','I','J','K','F','S'] #This list control the order of parameters + params = [ + "X", + "Y", + "Z", + "A", + "B", + "C", + "I", + "J", + "F", + "S", + "T", + "Q", + "R", + "L", + "K", + "P", + "O", + ] + + firstmove = Path.Command("G0", {"X": -1, "Y": -1, "Z": -1, "F": 0.0}) + currLocation.update(firstmove.Parameters) # set first location parameters + + if hasattr(pathobj, "Group"): # We have a compound or project. + if OUTPUT_COMMENTS: + out += ( + linenumber() + "(T)" + str.upper("compound: " + pathobj.Label) + "$\n" + ) + for p in pathobj.Group: + out += parse(p) + return out + else: # parsing simple path + + # groups might contain non-path things like stock. + if not hasattr(pathobj, "Path"): + return out + + for c in pathobj.Path.Commands: + outstring = [] + command = c.Name + # Convert G54-G59 Fixture offsets to E01-E06 for Dynapath Delta Control + if command in GCODE_MAP: + command = GCODE_MAP[command] + + if command.startswith("("): + if OUTPUT_COMMENTS: + command = "(T)" + str.upper(command) + "$" + + outstring.append(command) + + # if modal: suppress the command if it is the same as the last one + if MODAL is True: + if command == lastcommand: + outstring.pop(0) + + if c.Name[0] == "(" and not OUTPUT_COMMENTS: # command is a comment + continue + + # Now add the remaining parameters in order + for param in params: + if param in c.Parameters: + if param == "F" and ( + currLocation[param] != c.Parameters[param] or OUTPUT_DOUBLES + ): + if c.Name not in [ + "G0", + "G00", + ]: + speed = Units.Quantity( + c.Parameters["F"], FreeCAD.Units.Velocity + ) + if speed.getValueAs(UNIT_SPEED_FORMAT) > 0.0: + outstring.append( + param + + format( + float(speed.getValueAs(UNIT_SPEED_FORMAT)), + precision_string, + ) + ) + else: + continue + elif param == "Z" and ( + c.Parameters["Z"] == clearanceHeight + and c.Parameters["Z"] != lastZ + ): + x = 0 + y = 0 + outstring.insert( + 1, + "X" + + PostUtils.fmt(x, PRECISION, UNITS) + + "Y" + + PostUtils.fmt(y, PRECISION, UNITS), + ) + outstring.append( + param + PostUtils.fmt(c.Parameters["Z"], PRECISION, UNITS) + ) + elif param == "X" and (command in QCYCLE_RANGE): + pos = Units.Quantity(c.Parameters["X"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + elif param == "Y" and (command in QCYCLE_RANGE): + pos = Units.Quantity(c.Parameters["Y"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + # Remove X and Y betwen QCYCLE's since we already included them. + elif lastcommand in QCYCLE_RANGE and (param == "X" or "Y"): + outstring = [] + elif param == "S": + SPINDLE_SPEED = c.Parameters["S"] + outstring.append( + param + "{:.0f}".format(c.Parameters["S"]) + ) # Added formating to strip trailing .000 from RPM + elif param == "T": + outstring.append( + param + "{:.0f}".format(c.Parameters["T"]) + ) # Added formating to strip trailing .000 from Tool number + elif param == "I" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in I and J + i = c.Parameters["I"] + if ABSOLUTE_CIRCLE_CENTER: + i += lastX + outstring.append(param + PostUtils.fmt(i, PRECISION, UNITS)) + elif param == "J" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in I and J + j = c.Parameters["J"] + if ABSOLUTE_CIRCLE_CENTER: + j += lastY + outstring.append(param + PostUtils.fmt(j, PRECISION, UNITS)) + elif param == "K" and (command == "G2" or command == "G3"): + # Convert incremental arc center to absolute in K (Z axis arc) + k = c.Parameters["K"] + if ABSOLUTE_CIRCLE_CENTER: + k += lastZ + if command == ("G18" or "G19"): + outstring.append( + param + PostUtils.fmt(k, PRECISION, UNITS) + ) + elif param == "Q": + pos = Units.Quantity(c.Parameters["Q"], FreeCAD.Units.Length) + outstring.append( + "K" + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + elif (param == "R") and ((command in QCYCLE_RANGE)): + pos = Units.Quantity( + pathobj.ClearanceHeight.Value, FreeCAD.Units.Length + ) + outstring.insert( + 6, + "O" + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ), + ) # Insert "O" param for 2nd reference plane (Clearance Height) + pos = Units.Quantity(c.Parameters["R"], FreeCAD.Units.Length) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) # First Reference plan (Safe Height) + elif param == "P": + outstring.append( + "L" + format(c.Parameters[param], precision_string) + ) + else: + if ( + (not OUTPUT_DOUBLES) + and (param in currLocation) + and (currLocation[param] == c.Parameters[param]) + ): + continue + else: + pos = Units.Quantity( + c.Parameters[param], FreeCAD.Units.Length + ) + outstring.append( + param + + format( + float(pos.getValueAs(UNIT_FORMAT)), precision_string + ) + ) + + # save the last X, Y values + if "X" in c.Parameters: + lastX = c.Parameters["X"] + if "Y" in c.Parameters: + lastY = c.Parameters["Y"] + if "Z" in c.Parameters: + lastZ = c.Parameters["Z"] + + # store the latest command + lastcommand = command + currLocation.update(c.Parameters) + + # Check for Tool Change: + if command == "M6": + if OUTPUT_COMMENTS: + out += linenumber() + "(T)" + "BEGIN TOOLCHANGE$\n" + + if command == "message": + if OUTPUT_COMMENTS is False: + out = [] + else: + outstring.pop(0) # remove the command + # G98 is not used by dynapath and G99 is not used in Drilling/Boring/Tapping. + if c.Name == "G98" or (c.Name == "G99" and pathobj.Label == "Drilling"): + outstring = [] + + # prepend a line number and append a newline + if len(outstring) >= 1: + if OUTPUT_LINE_NUMBERS: + outstring.insert(0, (linenumber())) + + # append the line to the final output + for w in outstring: + out += w.strip() + COMMAND_SPACE + out += "\n" + + # Add a DWELL after spindle start based on RPM. + if DWELL_TIME > 0.0: + if command in ["M3", "M03", "M4", "M04"]: + DWELL_TIME = (SPINDLE_SPEED / 100) / 10 + out += linenumber() + "L%.1f\n" % DWELL_TIME + + return out + +print(__name__ + " gcode postprocessor loaded.") From b52d5a9038c8e43a269706dd57a1f9df0597710b Mon Sep 17 00:00:00 2001 From: luvtofish Date: Wed, 7 Dec 2022 10:24:01 -0600 Subject: [PATCH 24/26] removed print post processor print statement. --- src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py index ef4b864736..ff86a7b809 100644 --- a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -615,5 +615,3 @@ def parse(pathobj): out += linenumber() + "L%.1f\n" % DWELL_TIME return out - -print(__name__ + " gcode postprocessor loaded.") From f608438339dc35f53ff3302f04311c079e70b5bf Mon Sep 17 00:00:00 2001 From: luvtofish Date: Wed, 7 Dec 2022 20:49:40 -0600 Subject: [PATCH 25/26] Updated tooltip details --- src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py index ff86a7b809..12222852c4 100644 --- a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -42,8 +42,8 @@ and tested on FreeCAD Path workbench bundled with FreeCAD v20. This postprocessor, once placed in the appropriate PathScripts folder, can be used directly from inside FreeCAD, via the GUI importer or via python scripts with: -import delta_post -delta_post.export(object,"/path/to/file.ncc","") +import delta_4060_post +delta_4060_post.export(object,"/path/to/file.ncc","") """ parser = argparse.ArgumentParser(prog="delta_post", add_help=False) From 0d8aacae49b61b5d16d685033abcd80debd37145 Mon Sep 17 00:00:00 2001 From: luvtofish Date: Thu, 8 Dec 2022 08:47:10 -0600 Subject: [PATCH 26/26] tool tip changes --- src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py index 12222852c4..2a2a5a9259 100644 --- a/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py +++ b/src/Mod/Path/Path/Post/scripts/dynapath_4060_post.py @@ -38,7 +38,7 @@ TOOLTIP = """ This is a postprocessor file for the FreeCAD Path workbench. It is used to take a pseudo-gcode fragment outputted by a Path object, and output real GCode suitable for Dynapath Delta 40,50, & 60 Controls. It has been written -and tested on FreeCAD Path workbench bundled with FreeCAD v20. +and tested on FreeCAD Path workbench bundled with FreeCAD v21. This postprocessor, once placed in the appropriate PathScripts folder, can be used directly from inside FreeCAD, via the GUI importer or via python scripts with: @@ -46,7 +46,7 @@ import delta_4060_post delta_4060_post.export(object,"/path/to/file.ncc","") """ -parser = argparse.ArgumentParser(prog="delta_post", add_help=False) +parser = argparse.ArgumentParser(prog="delta_4060", add_help=False) parser.add_argument("--no-header", action="store_true", help="suppress header output") parser.add_argument( "--no-comments", action="store_true", help="suppress comment output" @@ -113,7 +113,7 @@ SPINDLE_SPEED = 0 UNITS = "G71" # G71 for metric, G70 for US standard UNIT_SPEED_FORMAT = "mm/min" UNIT_FORMAT = "mm" -MACHINE_NAME = "TreeCNC" +MACHINE_NAME = "Delta 4060" CORNER_MIN = {"x": 0, "y": 0, "z": 0} CORNER_MAX = {"x": 660, "y": 355, "z": 152} PRECISION = 3