From a1b3319bdf0063d005e6b92398257f7dd0e41ced Mon Sep 17 00:00:00 2001 From: Markus Lampert Date: Sun, 14 Aug 2022 11:56:28 -0700 Subject: [PATCH] Moved generators into Path.Base.Generator module --- src/Mod/Path/CMakeLists.txt | 62 ++++++++++++------- src/Mod/Path/Path/Base/Generator/__init__.py | 0 .../Base/Generator/drill.py} | 0 .../Base/Generator/helix.py} | 0 .../Base/Generator/rotation.py} | 0 .../Base/Generator/threadmilling.py} | 0 .../Base/Generator/toolchange.py} | 0 src/Mod/Path/Path/Op/Drilling.py | 4 +- src/Mod/Path/Path/Op/Helix.py | 4 +- src/Mod/Path/Path/Op/ThreadMilling.py | 2 +- src/Mod/Path/Path/Tool/Controller.py | 19 +++--- .../Path/PathTests/TestPathDrillGenerator.py | 2 +- .../Path/PathTests/TestPathHelixGenerator.py | 2 +- .../PathTests/TestPathRotationGenerator.py | 2 +- .../TestPathThreadMillingGenerator.py | 2 +- .../PathTests/TestPathToolChangeGenerator.py | 8 +-- 16 files changed, 60 insertions(+), 47 deletions(-) create mode 100644 src/Mod/Path/Path/Base/Generator/__init__.py rename src/Mod/Path/{Generators/drill_generator.py => Path/Base/Generator/drill.py} (100%) rename src/Mod/Path/{Generators/helix_generator.py => Path/Base/Generator/helix.py} (100%) rename src/Mod/Path/{Generators/rotation_generator.py => Path/Base/Generator/rotation.py} (100%) rename src/Mod/Path/{Generators/threadmilling_generator.py => Path/Base/Generator/threadmilling.py} (100%) rename src/Mod/Path/{Generators/toolchange_generator.py => Path/Base/Generator/toolchange.py} (100%) diff --git a/src/Mod/Path/CMakeLists.txt b/src/Mod/Path/CMakeLists.txt index 9537899f98..06076ec361 100644 --- a/src/Mod/Path/CMakeLists.txt +++ b/src/Mod/Path/CMakeLists.txt @@ -145,7 +145,7 @@ SET(PathPythonOp_SRCS Path/Op/Deburr.py Path/Op/Engrave.py Path/Op/EngraveBase.py - Path/Op/FeatureExtensions.py + Path/Op/FeatureExtension.py Path/Op/Drilling.py Path/Op/Helix.py Path/Op/MillFace.py @@ -175,7 +175,7 @@ SET(PathPythonOpGui_SRCS Path/Op/Gui/Deburr.py Path/Op/Gui/Drilling.py Path/Op/Gui/Engrave.py - Path/Op/Gui/FeatureExtensions.py + Path/Op/Gui/FeatureExtension.py Path/Op/Gui/Helix.py Path/Op/Gui/Hop.py Path/Op/Gui/MillFace.py @@ -211,12 +211,12 @@ SET(PathScripts_SRCS PathScripts/__init__.py ) -SET(Generator_SRCS - Generators/drill_generator.py - Generators/helix_generator.py - Generators/rotation_generator.py - Generators/threadmilling_generator.py - Generators/toolchange_generator.py +SET(PathPythonBaseGenerator_SRCS + Path/Base/Generator/drill.py + Path/Base/Generator/helix.py + Path/Base/Generator/rotation.py + Path/Base/Generator/threadmilling.py + Path/Base/Generator/toolchange.py ) SET(PathPythonGui_SRCS @@ -342,6 +342,9 @@ SET(Path_Data SET(all_files ${PathScripts_SRCS} ${PathPython_SRCS} + ${PathPythonBase_SRCS} + ${PathPythonBaseGui_SRCS} + ${PathPythonBaseGenerator_SRCS} ${PathPythonDressup_SRCS} ${PathPythonDressupGui_SRCS} ${PathPythonOp_SRCS} @@ -350,7 +353,6 @@ SET(all_files ${PathPythonPostScripts_SRCS} ${PathPythonTools_SRCS} ${PathPythonToolsGui_SRCS} - ${Generator_SRCS} ${PathPythonGui_SRCS} ${Tools_SRCS} ${Tools_Bit_SRCS} @@ -390,6 +392,27 @@ INSTALL( Mod/Path/Path ) +INSTALL( + FILES + ${PathPythonBase_SRCS} + DESTINATION + Mod/Path/Path/Base +) + +INSTALL( + FILES + ${PathPythonBaseGenerator_SRCS} + DESTINATION + Mod/Path/Path/Base/Generator +) + +INSTALL( + FILES + ${PathPythonBaseGui_SRCS} + DESTINATION + Mod/Path/Path/Base/Gui +) + INSTALL( FILES ${PathPythonDressup_SRCS} @@ -424,6 +447,13 @@ INSTALL( Mod/Path/Path/Post ) +INSTALL( + FILES + ${PathPythonPostScripts_SRCS} + DESTINATION + Mod/Path/Path/Post/scripts +) + INSTALL( FILES ${PathPythonTools_SRCS} @@ -438,20 +468,6 @@ INSTALL( Mod/Path/Path/Tool/Gui ) -INSTALL( - FILES - ${PathPythonPostScripts_SRCS} - DESTINATION - Mod/Path/Path/Post/scripts -) - -INSTALL( - FILES - ${Generator_SRCS} - DESTINATION - Mod/Path/Generators -) - INSTALL( FILES ${PathTests_SRCS} diff --git a/src/Mod/Path/Path/Base/Generator/__init__.py b/src/Mod/Path/Path/Base/Generator/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/src/Mod/Path/Generators/drill_generator.py b/src/Mod/Path/Path/Base/Generator/drill.py similarity index 100% rename from src/Mod/Path/Generators/drill_generator.py rename to src/Mod/Path/Path/Base/Generator/drill.py diff --git a/src/Mod/Path/Generators/helix_generator.py b/src/Mod/Path/Path/Base/Generator/helix.py similarity index 100% rename from src/Mod/Path/Generators/helix_generator.py rename to src/Mod/Path/Path/Base/Generator/helix.py diff --git a/src/Mod/Path/Generators/rotation_generator.py b/src/Mod/Path/Path/Base/Generator/rotation.py similarity index 100% rename from src/Mod/Path/Generators/rotation_generator.py rename to src/Mod/Path/Path/Base/Generator/rotation.py diff --git a/src/Mod/Path/Generators/threadmilling_generator.py b/src/Mod/Path/Path/Base/Generator/threadmilling.py similarity index 100% rename from src/Mod/Path/Generators/threadmilling_generator.py rename to src/Mod/Path/Path/Base/Generator/threadmilling.py diff --git a/src/Mod/Path/Generators/toolchange_generator.py b/src/Mod/Path/Path/Base/Generator/toolchange.py similarity index 100% rename from src/Mod/Path/Generators/toolchange_generator.py rename to src/Mod/Path/Path/Base/Generator/toolchange.py diff --git a/src/Mod/Path/Path/Op/Drilling.py b/src/Mod/Path/Path/Op/Drilling.py index bd60e7c922..b21a03dfb4 100644 --- a/src/Mod/Path/Path/Op/Drilling.py +++ b/src/Mod/Path/Path/Op/Drilling.py @@ -24,11 +24,11 @@ from __future__ import print_function -from Generators import drill_generator as generator import FreeCAD import Part import Path import Path.Base.FeedRate as PathFeedRate +import Path.Base.Generator.drill as drill import Path.Base.MachineState as PathMachineState import Path.Op.Base as PathOp import Path.Op.CircularHoleBase as PathCircularHoleBase @@ -248,7 +248,7 @@ class ObjectDrilling(PathCircularHoleBase.ObjectOp): chipBreak = (obj.chipBreakEnabled and obj.PeckEnabled) try: - drillcommands = generator.generate( + drillcommands = drill.generate( edge, dwelltime, peckdepth, diff --git a/src/Mod/Path/Path/Op/Helix.py b/src/Mod/Path/Path/Op/Helix.py index c6af036821..efc94c4f2c 100644 --- a/src/Mod/Path/Path/Op/Helix.py +++ b/src/Mod/Path/Path/Op/Helix.py @@ -20,7 +20,7 @@ # * * # *************************************************************************** -from Generators import helix_generator +import Path.Base.Generator.helix as helix from PathScripts.PathUtils import fmt from PathScripts.PathUtils import sort_locations from PySide.QtCore import QT_TRANSLATE_NOOP @@ -218,7 +218,7 @@ class ObjectHelix(PathCircularHoleBase.ObjectOp): ) ) - results = helix_generator.generate(**args) + results = helix.generate(**args) for command in results: self.commandlist.append(command) diff --git a/src/Mod/Path/Path/Op/ThreadMilling.py b/src/Mod/Path/Path/Op/ThreadMilling.py index bd634d057d..144098273a 100644 --- a/src/Mod/Path/Path/Op/ThreadMilling.py +++ b/src/Mod/Path/Path/Op/ThreadMilling.py @@ -24,9 +24,9 @@ from __future__ import print_function import FreeCAD import Path +import Path.Base.Generator.threadmilling as threadmilling import Path.Op.Base as PathOp import Path.Op.CircularHoleBase as PathCircularHoleBase -import Generators.threadmilling_generator as threadmilling import math from PySide.QtCore import QT_TRANSLATE_NOOP diff --git a/src/Mod/Path/Path/Tool/Controller.py b/src/Mod/Path/Path/Tool/Controller.py index ee90b9925d..1426adf058 100644 --- a/src/Mod/Path/Path/Tool/Controller.py +++ b/src/Mod/Path/Path/Tool/Controller.py @@ -26,8 +26,7 @@ from PySide.QtCore import QT_TRANSLATE_NOOP import FreeCAD import Path import Path.Tool.Bit as PathToolBit -from Generators import toolchange_generator as toolchange_generator -from Generators.toolchange_generator import SpindleDirection +import Path.Base.Generator.toolchange as toolchange if False: @@ -253,27 +252,27 @@ class ToolController: "toolnumber": obj.ToolNumber, "toollabel": obj.Label, "spindlespeed": obj.SpindleSpeed, - "spindledirection": SpindleDirection.OFF, + "spindledirection": toolchange.SpindleDirection.OFF, } if hasattr(obj.Tool, "SpindlePower"): if not obj.Tool.SpindlePower: - args["spindledirection"] = SpindleDirection.OFF + args["spindledirection"] = toolchange.SpindleDirection.OFF else: if obj.SpindleDir == "Forward": - args["spindledirection"] = SpindleDirection.CW + args["spindledirection"] = toolchange.SpindleDirection.CW else: - args["spindledirection"] = SpindleDirection.CCW + args["spindledirection"] = toolchange.SpindleDirection.CCW elif obj.SpindleDir == "None": - args["spindledirection"] = SpindleDirection.OFF + args["spindledirection"] = toolchange.SpindleDirection.OFF else: if obj.SpindleDir == "Forward": - args["spindledirection"] = SpindleDirection.CW + args["spindledirection"] = toolchange.SpindleDirection.CW else: - args["spindledirection"] = SpindleDirection.CCW + args["spindledirection"] = toolchange.SpindleDirection.CCW - commands = toolchange_generator.generate(**args) + commands = toolchange.generate(**args) path = Path.Path(commands) obj.Path = path diff --git a/src/Mod/Path/PathTests/TestPathDrillGenerator.py b/src/Mod/Path/PathTests/TestPathDrillGenerator.py index 0f71f05379..15ae13bd8b 100644 --- a/src/Mod/Path/PathTests/TestPathDrillGenerator.py +++ b/src/Mod/Path/PathTests/TestPathDrillGenerator.py @@ -21,9 +21,9 @@ # *************************************************************************** import FreeCAD -import Generators.drill_generator as generator import Part import Path +import Path.Base.Generator.drill as generator import PathTests.PathTestUtils as PathTestUtils Path.Log.setLevel(Path.Log.Level.INFO, Path.Log.thisModule()) diff --git a/src/Mod/Path/PathTests/TestPathHelixGenerator.py b/src/Mod/Path/PathTests/TestPathHelixGenerator.py index 170552ed7d..274ea84c89 100644 --- a/src/Mod/Path/PathTests/TestPathHelixGenerator.py +++ b/src/Mod/Path/PathTests/TestPathHelixGenerator.py @@ -23,7 +23,7 @@ import FreeCAD import Part import Path -import Generators.helix_generator as generator +import Path.Base.Generator.helix as generator import PathTests.PathTestUtils as PathTestUtils diff --git a/src/Mod/Path/PathTests/TestPathRotationGenerator.py b/src/Mod/Path/PathTests/TestPathRotationGenerator.py index ff14f659df..78f6dbb0ad 100644 --- a/src/Mod/Path/PathTests/TestPathRotationGenerator.py +++ b/src/Mod/Path/PathTests/TestPathRotationGenerator.py @@ -21,8 +21,8 @@ # *************************************************************************** import FreeCAD -import Generators.rotation_generator as generator import Path +import Path.Base.Generator.rotation as generator import PathTests.PathTestUtils as PathTestUtils import numpy as np diff --git a/src/Mod/Path/PathTests/TestPathThreadMillingGenerator.py b/src/Mod/Path/PathTests/TestPathThreadMillingGenerator.py index c33368cc7d..cfc3ad7ca9 100644 --- a/src/Mod/Path/PathTests/TestPathThreadMillingGenerator.py +++ b/src/Mod/Path/PathTests/TestPathThreadMillingGenerator.py @@ -21,7 +21,7 @@ # *************************************************************************** import FreeCAD -import Generators.threadmilling_generator as threadmilling +import Path.Base.Generator.threadmilling as threadmilling import math from PathTests.PathTestUtils import PathTestBase diff --git a/src/Mod/Path/PathTests/TestPathToolChangeGenerator.py b/src/Mod/Path/PathTests/TestPathToolChangeGenerator.py index 17827dc523..72b0cf80ee 100644 --- a/src/Mod/Path/PathTests/TestPathToolChangeGenerator.py +++ b/src/Mod/Path/PathTests/TestPathToolChangeGenerator.py @@ -21,9 +21,7 @@ # *************************************************************************** import Path -import Generators.toolchange_generator as generator -from Generators.toolchange_generator import SpindleDirection - +import Path.Base.Generator.toolchange as generator import PathTests.PathTestUtils as PathTestUtils Path.Log.setLevel(Path.Log.Level.DEBUG, Path.Log.thisModule()) @@ -38,7 +36,7 @@ class TestPathToolChangeGenerator(PathTestUtils.PathTestBase): "toolnumber": 1, "toollabel": "My Label", "spindlespeed": 500, - "spindledirection": SpindleDirection.OFF, + "spindledirection": generator.SpindleDirection.OFF, } results = generator.generate(**args) @@ -54,7 +52,7 @@ class TestPathToolChangeGenerator(PathTestUtils.PathTestBase): self.assertTrue(toolcommand.Name == "M6") # Turn on the spindle - args["spindledirection"] = SpindleDirection.CW + args["spindledirection"] = generator.SpindleDirection.CW results = generator.generate(**args) self.assertTrue(len(results) == 3)