From 71317baa52ad3dee760b167d10e97d23eb4f28e3 Mon Sep 17 00:00:00 2001 From: mosfet80 Date: Mon, 14 Apr 2025 18:05:55 +0200 Subject: [PATCH] MOD: assembly clean (#20557) * MOD: assembly clean clean code * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Update AssemblyLink.cpp --------- Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> --- src/Mod/Assembly/App/AssemblyLink.cpp | 2 - .../Assembly/AssemblyTests/TestTEMPLATE.py | 3 -- src/Mod/Assembly/CommandCreateSimulation.py | 2 - src/Mod/Assembly/CommandCreateView.py | 1 - src/Mod/Assembly/CommandExportASMT.py | 1 - src/Mod/Assembly/CommandInsertLink.py | 50 ------------------- src/Mod/Assembly/CommandSolveAssembly.py | 1 - src/Mod/Assembly/UtilsAssembly.py | 1 - 8 files changed, 61 deletions(-) diff --git a/src/Mod/Assembly/App/AssemblyLink.cpp b/src/Mod/Assembly/App/AssemblyLink.cpp index 7df49b12e7..774d2fd638 100644 --- a/src/Mod/Assembly/App/AssemblyLink.cpp +++ b/src/Mod/Assembly/App/AssemblyLink.cpp @@ -491,8 +491,6 @@ JointGroup* AssemblyLink::ensureJointGroup() jGroup = new JointGroup(); getDocument()->addObject(jGroup, tr("Joints").toStdString().c_str()); - // we want to add jgroup at the start, so we don't use - // addObject(jGroup); std::vector grp = Group.getValues(); grp.insert(grp.begin(), jGroup); Group.setValues(grp); diff --git a/src/Mod/Assembly/AssemblyTests/TestTEMPLATE.py b/src/Mod/Assembly/AssemblyTests/TestTEMPLATE.py index d69d18f9b5..3281c05878 100644 --- a/src/Mod/Assembly/AssemblyTests/TestTEMPLATE.py +++ b/src/Mod/Assembly/AssemblyTests/TestTEMPLATE.py @@ -49,9 +49,6 @@ class TestTEMPLATE(unittest.TestCase): """ pass - # Close geometry document without saving - # FreeCAD.closeDocument(FreeCAD.ActiveDocument.Name) - # Setup and tear down methods called before and after each unit test def setUp(self): """setUp()... diff --git a/src/Mod/Assembly/CommandCreateSimulation.py b/src/Mod/Assembly/CommandCreateSimulation.py index 595ccc2295..444d8593b3 100644 --- a/src/Mod/Assembly/CommandCreateSimulation.py +++ b/src/Mod/Assembly/CommandCreateSimulation.py @@ -175,7 +175,6 @@ class Simulation: def execute(self, feaPy): """Do something when doing a recomputation, this method is mandatory""" - # App.Console.PrintMessage("Recompute Python Box feature\n") pass def getAssembly(self, feaPy): @@ -329,7 +328,6 @@ class Motion: def execute(self, feaPy): """Do something when doing a recomputation, this method is mandatory""" - # App.Console.PrintMessage("Recompute Python Box feature\n") pass def getSimulation(self, feaPy): diff --git a/src/Mod/Assembly/CommandCreateView.py b/src/Mod/Assembly/CommandCreateView.py index 767614af35..f68d620e49 100644 --- a/src/Mod/Assembly/CommandCreateView.py +++ b/src/Mod/Assembly/CommandCreateView.py @@ -38,7 +38,6 @@ if App.GuiUp: import UtilsAssembly import Preferences -# translate = App.Qt.translate __title__ = "Assembly Command Create Exploded View" __author__ = "Ondsel" diff --git a/src/Mod/Assembly/CommandExportASMT.py b/src/Mod/Assembly/CommandExportASMT.py index 975a752584..1964393e81 100644 --- a/src/Mod/Assembly/CommandExportASMT.py +++ b/src/Mod/Assembly/CommandExportASMT.py @@ -30,7 +30,6 @@ from PySide.QtWidgets import QFileDialog if App.GuiUp: import FreeCADGui as Gui -# translate = App.Qt.translate __title__ = "Assembly Command Create Assembly" __author__ = "Ondsel" diff --git a/src/Mod/Assembly/CommandInsertLink.py b/src/Mod/Assembly/CommandInsertLink.py index c31629dd40..7617109e6b 100644 --- a/src/Mod/Assembly/CommandInsertLink.py +++ b/src/Mod/Assembly/CommandInsertLink.py @@ -36,7 +36,6 @@ import UtilsAssembly import Preferences import CommandCreateJoint -# translate = App.Qt.translate __title__ = "Assembly Command Insert Component" __author__ = "Ondsel" @@ -145,8 +144,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): def accept(self): self.deactivated() - # if self.partMoving: - # self.endMove() Gui.addModule("UtilsAssembly") commands = "assembly = UtilsAssembly.activeAssembly()\n" for insertionItem in self.insertionStack: @@ -179,9 +176,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): def reject(self): self.deactivated() - # if self.partMoving: - # self.dismissPart() - App.closeActiveTransaction(True) return True @@ -335,9 +329,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): item.setExpanded(not item.isExpanded()) return - # if self.partMoving: - # self.endMove() - # check that the current document had been saved or that it's the same document as that of the selected part if not self.doc == selectedPart.Document: if self.doc.FileName == "": @@ -434,11 +425,7 @@ class TaskAssemblyInsertLink(QtCore.QObject): Gui.Selection.clearSelection() Gui.Selection.addSelection(self.doc.Name, addedObject.Name, "") - # Start moving the part if user brings mouse on view - # self.initMove() - item.setSelected(False) - # self.form.partList.setItemSelected(item, False) if len(self.insertionStack) == 1 and not UtilsAssembly.isAssemblyGrounded(): self.handleFirstInsertion() @@ -481,7 +468,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): self.groundedObj = self.insertionStack[0]["addedObject"] self.groundedJoint = CommandCreateJoint.createGroundedJoint(self.groundedObj) - # self.endMove() def increment_counter(self, item): text = item.text(0) @@ -514,24 +500,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): item.setText(0, new_text) - # def initMove(self): - # self.callbackMove = self.view.addEventCallback("SoLocation2Event", self.moveMouse) - # self.callbackClick = self.view.addEventCallback("SoMouseButtonEvent", self.clickMouse) - # self.callbackKey = self.view.addEventCallback("SoKeyboardEvent", self.KeyboardEvent) - # self.partMoving = True - - # def endMove(self): - # self.view.removeEventCallback("SoLocation2Event", self.callbackMove) - # self.view.removeEventCallback("SoMouseButtonEvent", self.callbackClick) - # self.view.removeEventCallback("SoKeyboardEvent", self.callbackKey) - # self.partMoving = False - # self.doc.recompute() - # # Gui.Selection.removeSelectionGate() - - # def moveMouse(self, info): - # newPos = self.view.getPoint(*info["Position"]) - # self.insertionStack[-1]["addedObject"].Placement.Base = newPos - """def clickMouse(self, info): if info["Button"] == "BUTTON1" and info["State"] == "DOWN": Gui.Selection.clearSelection() @@ -559,24 +527,8 @@ class TaskAssemblyInsertLink(QtCore.QObject): elif info["Button"] == "BUTTON2" and info["State"] == "DOWN": self.dismissPart()""" - # 3D view keyboard handler - # def KeyboardEvent(self, info): - # if info["State"] == "UP" and info["Key"] == "ESCAPE": - # self.dismissPart() - - # def dismissPart(self): - # self.endMove() - # stack_item = self.insertionStack.pop() - # self.totalTranslation -= stack_item["translation"] - # UtilsAssembly.removeObjAndChilds(stack_item["addedObject"]) - # self.decrement_counter(stack_item["item"]) - # Taskbox keyboard event handler def eventFilter(self, watched, event): - # if watched == self.form and event.type() == QtCore.QEvent.KeyPress: - # if event.key() == QtCore.Qt.Key_Escape and self.partMoving: - # self.dismissPart() - # return True # Consume the event if event.type() == QtCore.QEvent.ContextMenu and watched is self.form.partList: item = watched.itemAt(event.pos()) @@ -587,8 +539,6 @@ class TaskAssemblyInsertLink(QtCore.QObject): stack_item = self.insertionStack[i] if stack_item["item"] == item: - # if self.partMoving: - # self.endMove() self.totalTranslation -= stack_item["translation"] obj = stack_item["addedObject"] diff --git a/src/Mod/Assembly/CommandSolveAssembly.py b/src/Mod/Assembly/CommandSolveAssembly.py index 37d7c60aaa..84b708fa27 100644 --- a/src/Mod/Assembly/CommandSolveAssembly.py +++ b/src/Mod/Assembly/CommandSolveAssembly.py @@ -33,7 +33,6 @@ if App.GuiUp: import UtilsAssembly import Assembly_rc -# translate = App.Qt.translate __title__ = "Assembly Command to Solve Assembly" __author__ = "Ondsel" diff --git a/src/Mod/Assembly/UtilsAssembly.py b/src/Mod/Assembly/UtilsAssembly.py index 0830a7ccc9..4e2f4a2177 100644 --- a/src/Mod/Assembly/UtilsAssembly.py +++ b/src/Mod/Assembly/UtilsAssembly.py @@ -109,7 +109,6 @@ def number_of_components_in(assembly): if not obj.isDerivedFrom("App::GeoFeature"): continue - # if obj.isDerivedFrom("App::DatumElement") or obj.isDerivedFrom("App::LocalCoordinateSystem"): if obj.isDerivedFrom("App::Origin"): # after https://github.com/FreeCAD/FreeCAD/pull/16675 merges, # replace the App::Origin test by the one above