From fbceff0fdf4afa419301c8027189eff66881fb6c Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:23:59 +0200 Subject: [PATCH 1/5] Delete gui_lineops.py --- src/Mod/Draft/draftguitools/gui_lineops.py | 166 --------------------- 1 file changed, 166 deletions(-) delete mode 100644 src/Mod/Draft/draftguitools/gui_lineops.py diff --git a/src/Mod/Draft/draftguitools/gui_lineops.py b/src/Mod/Draft/draftguitools/gui_lineops.py deleted file mode 100644 index afa9f7722b..0000000000 --- a/src/Mod/Draft/draftguitools/gui_lineops.py +++ /dev/null @@ -1,166 +0,0 @@ -# *************************************************************************** -# * (c) 2009, 2010 Yorik van Havre * -# * (c) 2009, 2010 Ken Cline * -# * (c) 2020 Eliud Cabrera Castillo * -# * * -# * 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 Library 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 * -# * * -# *************************************************************************** -"""Provides GUI tools to do certain line operations. - -These GuiCommands aren't really used anymore, as the same actions -are called from the task panel interface by other methods. -""" -## @package gui_lineops -# \ingroup draftguitools -# \brief Provides GUI tools to do certain line operations. - -## \addtogroup draftguitools -# @{ -from PySide.QtCore import QT_TRANSLATE_NOOP - -import FreeCAD as App -import FreeCADGui as Gui -import Draft_rc -import draftguitools.gui_base as gui_base - -from draftutils.messages import _msg -from draftutils.translate import translate - -# The module is used to prevent complaints from code checkers (flake8) -True if Draft_rc.__name__ else False - - -class LineAction(gui_base.GuiCommandSimplest): - """Base class for Line context GuiCommands. - - This is inherited by the other GuiCommand classes to run - a set of similar actions when editing a line, wire, spline, - or bezier curve. - - It inherits `GuiCommandSimplest` to set up the document - and other behavior. See this class for more information. - """ - - def Activated(self, action="None"): - """Execute when the command is called. - - Parameters - ---------- - action: str - Indicates the type of action to perform with the line object. - It can be `'finish'`, `'close'`, or `'undo'`. - """ - if hasattr(App, "activeDraftCommand"): - _command = App.activeDraftCommand - else: - _msg(translate("draft","No active command.")) - return - - if (_command is not None - and _command.featureName in ("Line", "Polyline", - "BSpline", "BezCurve", - "CubicBezCurve")): - if action == "finish": - _command.finish(False) - elif action == "close": - _command.finish(True) - elif action == "undo": - _command.undolast() - - -class FinishLine(LineAction): - """GuiCommand to finish any running line drawing operation.""" - - def __init__(self): - super(FinishLine, self).__init__(name=translate("draft","Finish line")) - - def GetResources(self): - """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_Finish', - 'MenuText': QT_TRANSLATE_NOOP("Draft_FinishLine", "Finish line"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_FinishLine", "Finishes a line without closing it."), - 'CmdType': 'ForEdit'} - return d - - def Activated(self): - """Execute when the command is called. - - It calls the `finish(False)` method of the active Draft command. - """ - super(FinishLine, self).Activated(action="finish") - - -Gui.addCommand('Draft_FinishLine', FinishLine()) - - -class CloseLine(LineAction): - """GuiCommand to close the line being drawn and finish the operation.""" - - def __init__(self): - super(CloseLine, self).__init__(name=translate("draft","Close line")) - - def GetResources(self): - """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_Lock', - 'MenuText': QT_TRANSLATE_NOOP("Draft_CloseLine", "Close Line"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_CloseLine", "Closes the line being drawn, and finishes the operation."), - 'CmdType': 'ForEdit'} - return d - - def Activated(self): - """Execute when the command is called. - - It calls the `finish(True)` method of the active Draft command. - """ - super(CloseLine, self).Activated(action="close") - - -Gui.addCommand('Draft_CloseLine', CloseLine()) - - -class UndoLine(LineAction): - """GuiCommand to undo the last drawn segment of a line.""" - - def __init__(self): - super(UndoLine, self).__init__(name=translate("draft","Undo line")) - - def GetResources(self): - """Set icon, menu and tooltip.""" - - d = {'Pixmap': 'Draft_Rotate', - 'MenuText': QT_TRANSLATE_NOOP("Draft_UndoLine", - "Undo last segment"), - 'ToolTip': QT_TRANSLATE_NOOP("Draft_UndoLine", "Undoes the last drawn segment of the line being drawn."), - 'CmdType': 'ForEdit'} - return d - - def Activated(self): - """Execute when the command is called. - - It calls the `undolast` method of the active Draft command. - """ - super(UndoLine, self).Activated(action="undo") - - -Gui.addCommand('Draft_UndoLine', UndoLine()) - -## @} From d99ad042b1961a62b5702efc585ee4c1b59c0120 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:28:08 +0200 Subject: [PATCH 2/5] Draft: fix context menu Remove gui_lineops.py --- src/Mod/Draft/CMakeLists.txt | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Mod/Draft/CMakeLists.txt b/src/Mod/Draft/CMakeLists.txt index c21df3f9e7..1836ad035c 100644 --- a/src/Mod/Draft/CMakeLists.txt +++ b/src/Mod/Draft/CMakeLists.txt @@ -265,7 +265,6 @@ SET(Draft_GUI_tools draftguitools/gui_edit_part_objects.py draftguitools/gui_edit_sketcher_objects.py draftguitools/gui_edit.py - draftguitools/gui_lineops.py draftguitools/gui_togglemodes.py draftguitools/gui_groups.py draftguitools/gui_grid.py From eb0c45ce638e665ceb38c2ff8cb87b1b4cd6918a Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:30:04 +0200 Subject: [PATCH 3/5] Draft: fix context menu Remove the 3 gui_lineops items. --- src/Mod/Draft/DraftTools.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Mod/Draft/DraftTools.py b/src/Mod/Draft/DraftTools.py index d9e0df2f6a..f0cef4e713 100644 --- a/src/Mod/Draft/DraftTools.py +++ b/src/Mod/Draft/DraftTools.py @@ -78,9 +78,6 @@ import draftguitools.gui_edit import draftguitools.gui_selectplane import draftguitools.gui_setstyle import draftguitools.gui_planeproxy -from draftguitools.gui_lineops import FinishLine -from draftguitools.gui_lineops import CloseLine -from draftguitools.gui_lineops import UndoLine from draftguitools.gui_togglemodes import ToggleConstructionMode from draftguitools.gui_togglemodes import ToggleContinueMode from draftguitools.gui_togglemodes import ToggleDisplayMode From f03dfe351e5fd0bf265b53fa28b7366609b03c01 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:32:36 +0200 Subject: [PATCH 4/5] Draft: fix context menu Remove the get_draft_line_commands function. Update the def get_draft_context_commands function. --- src/Mod/Draft/draftutils/init_tools.py | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index 5851a91315..b1f6fbce60 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -159,22 +159,20 @@ def get_draft_snap_commands(): def get_draft_context_commands(): """Return the context menu commands list.""" - return ["Draft_ApplyStyle", - "Draft_ToggleDisplayMode", + return ["Draft_SetStyle", + "Draft_ApplyStyle", + "Separator", + "Draft_Layer", "Draft_AddNamedGroup", "Draft_AddToGroup", "Draft_SelectGroup", - "Draft_SelectPlane", - "Draft_ShowSnapBar", + "Draft_ToggleConstructionMode", + "Draft_AddConstruction", + "Separator", + "Draft_ToggleDisplayMode", "Draft_ToggleGrid", - "Draft_SetStyle"] - - -def get_draft_line_commands(): - """Return the line commands list.""" - return ["Draft_UndoLine", - "Draft_FinishLine", - "Draft_CloseLine"] + "Draft_SelectPlane", + "Draft_WorkingPlaneProxy"] def init_toolbar(workbench, toolbar, cmd_list): From 482cf61025dbf2aad90cbf0188ac0991fefc206c Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 12 Oct 2021 14:35:36 +0200 Subject: [PATCH 5/5] Draft: fix context menu Remove call to get_draft_line_commands. Update the ContextMenu function. The items are based on the utilities menu now. And the context menu is the same for the Tree view and the 3D view. --- src/Mod/Draft/InitGui.py | 21 +-------------------- 1 file changed, 1 insertion(+), 20 deletions(-) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index 1952d50e0c..3d90e2f0be 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -98,7 +98,6 @@ class DraftWorkbench(FreeCADGui.Workbench): self.utility_commands_menu = it.get_draft_utility_commands_menu() self.utility_commands_toolbar = it.get_draft_utility_commands_toolbar() self.context_commands = it.get_draft_context_commands() - self.line_commands = it.get_draft_line_commands() # Set up toolbars it.init_toolbar(self, @@ -162,25 +161,7 @@ class DraftWorkbench(FreeCADGui.Workbench): def ContextMenu(self, recipient): """Define an optional custom context menu.""" - from DraftGui import translate - if recipient == "View": - if FreeCAD.activeDraftCommand is None: - if FreeCADGui.Selection.getSelection(): - self.appendContextMenu("Draft", self.drawing_commands + self.modification_commands) - self.appendContextMenu("Utilities", self.context_commands) - else: - self.appendContextMenu("Draft", self.drawing_commands) - else: - if FreeCAD.activeDraftCommand.featureName in ("Line", - "Wire", - "Polyline", - "BSpline", - "BezCurve", - "CubicBezCurve"): - self.appendContextMenu("", self.line_commands) - else: - if FreeCADGui.Selection.getSelection(): - self.appendContextMenu("Utilities", self.context_commands) + self.appendContextMenu("Utilities", self.context_commands) def GetClassName(self): """Type of workbench."""