From a1499c297e7b222f6fa67c404676684dece1420b Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:49:22 +0200 Subject: [PATCH 1/6] Draft: fix shortcuts in menus and more (InitGui.py) --- src/Mod/Draft/InitGui.py | 46 +++++++++++++++++++++++++++++----------- 1 file changed, 34 insertions(+), 12 deletions(-) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index 8802be6af4..ced2528c63 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -92,25 +92,47 @@ class DraftWorkbench(FreeCADGui.Workbench): # Set up command lists import draftutils.init_tools as it - self.drawing_commands = it.get_draft_drawing_commands() + if hasattr(it, "get_draft_drawing_commands_temp"): + self.drawing_commands = it.get_draft_drawing_commands_temp() + else: + self.drawing_commands = it.get_draft_drawing_commands() self.annotation_commands = it.get_draft_annotation_commands() - self.modification_commands = it.get_draft_modification_commands() + if hasattr(it, "get_draft_modification_commands_temp"): + self.modification_commands = it.get_draft_modification_commands_temp() + else: + self.modification_commands = it.get_draft_modification_commands() + 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() - self.utility_commands = it.get_draft_utility_commands() - self.utility_small = it.get_draft_small_commands() # Set up toolbars - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), self.drawing_commands) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), self.annotation_commands) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), self.modification_commands) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft utility tools"), self.utility_small) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), + self.drawing_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), + self.annotation_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), + self.modification_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft utility tools"), + self.utility_commands_toolbar) # Set up menus - self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), self.drawing_commands) - self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"), self.annotation_commands) - self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"), self.modification_commands) - self.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"), self.utility_commands + self.context_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Draft", "&Drafting")], + self.drawing_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Draft", "&Annotation")], + self.annotation_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Draft", "&Modification")], + self.modification_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Draft", "&Utilities")], + self.utility_commands_menu) # Set up preferences pages if hasattr(FreeCADGui, "draftToolBar"): From f4ce6a8291856fba21c089062a3148d525ba8f28 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 28 Sep 2021 14:50:41 +0200 Subject: [PATCH 2/6] Draft: fix shortcuts in menus and more (init_tools.py) --- src/Mod/Draft/draftutils/init_tools.py | 174 +++++++++++++++++++------ 1 file changed, 137 insertions(+), 37 deletions(-) diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index 4812575d82..a2c5454db1 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -1,5 +1,6 @@ # *************************************************************************** -# * (c) 2020 Eliud Cabrera Castillo * +# * Copyright (c) 2020 Eliud Cabrera Castillo * +# * Copyright (c) 2021 FreeCAD Developers * # * * # * This file is part of the FreeCAD CAx development system. * # * * @@ -20,13 +21,9 @@ # * USA * # * * # *************************************************************************** -"""Provides lists of commands in order to set up toolbars of the workbench. -This module returns lists of commands, so that the toolbars -can be initialized by Draft, and by other workbenches. -These commands should be defined in `DraftTools`, and in the individual -modules in `draftguitools`. -""" +"""Provides functions and lists of commands to set up Draft menus and toolbars.""" + ## @package init_tools # \ingroup draftutils # \brief Provides lists of commands to set up toolbars of the workbench. @@ -48,6 +45,35 @@ def get_draft_drawing_commands(): "Draft_ShapeString","Draft_Hatch"] +# This function replaces get_draft_drawing_commands. +# The "_temp" suffix should be removed when the BIM Workbench has been updated. +def get_draft_drawing_commands_temp(): + """Return the drawing commands list.""" + from draftguitools import gui_arcs + from draftguitools import gui_beziers + arc_group = gui_arcs.ArcGroup + bez_group = gui_beziers.BezierGroup + + return ["Draft_Line", + "Draft_Wire", + "Draft_Fillet", + ([QT_TRANSLATE_NOOP("Draft", "Arc tools")], + list(arc_group.GetCommands(arc_group))), # tuple len=2: submenu + ("Draft_ArcTools", ), # tuple len=1: toolbar flyout + "Draft_Circle", + "Draft_Ellipse", + "Draft_Rectangle", + "Draft_Polygon", + "Draft_BSpline", + ([QT_TRANSLATE_NOOP("Draft", "Bezier tools")], + list(bez_group.GetCommands(bez_group))), + ("Draft_BezierTools", ), + "Draft_Point", + "Draft_Facebinder", + "Draft_ShapeString", + "Draft_Hatch"] + + def get_draft_annotation_commands(): """Return the annotation commands list.""" return ["Draft_Text", "Draft_Dimension", @@ -59,6 +85,8 @@ def get_draft_array_commands(): return ["Draft_ArrayTools"] +# This function has been replaced by get_draft_utility_commands_toolbar. +# It should be removed when the BIM Workbench has been updated. def get_draft_small_commands(): """Return a list with only some utilities.""" return ["Draft_Layer", @@ -92,6 +120,42 @@ def get_draft_modification_commands(): return lst +# This function replaces get_draft_modification_commands. +# The "_temp" suffix should be removed when the BIM Workbench has been updated. +def get_draft_modification_commands_temp(): + """Return the modification commands list.""" + from draftguitools import gui_arrays + arr_group = gui_arrays.ArrayGroup + + return ["Draft_Move", + "Draft_Rotate", + "Draft_Scale", + "Draft_Mirror", + "Draft_Offset", + "Draft_Trimex", + "Draft_Stretch", + "Separator", + "Draft_Clone", + ([QT_TRANSLATE_NOOP("Draft", "Array tools")], + list(arr_group.GetCommands(arr_group))), # tuple len=2: submenu + ("Draft_ArrayTools", ), # tuple len=1: toolbar flyout + "Separator", + "Draft_Edit", + "Draft_SubelementHighlight", + "Separator", + "Draft_Join", + "Draft_Split", + "Draft_Upgrade", + "Draft_Downgrade", + "Separator", + "Draft_WireToBSpline", + "Draft_Draft2Sketch", + "Draft_Slope", + "Draft_FlipDimension", + "Separator", + "Draft_Shape2DView"] + + def get_draft_context_commands(): """Return the context menu commands list.""" return ["Draft_ApplyStyle", "Draft_ToggleDisplayMode", @@ -106,6 +170,8 @@ def get_draft_line_commands(): "Draft_CloseLine"] +# This function has been replaced by get_draft_utility_commands_menu. +# It should be removed when the BIM Workbench has been updated. def get_draft_utility_commands(): """Return the utility commands list.""" return ["Draft_Layer", @@ -116,6 +182,39 @@ def get_draft_utility_commands(): "Draft_AddConstruction"] +def get_draft_utility_commands_menu(): + """Return the utility commands list for the menu.""" + return ["Draft_SetStyle", + "Draft_ApplyStyle", + "Separator", + "Draft_Layer", + "Draft_AddNamedGroup", + "Draft_AddToGroup", + "Draft_SelectGroup", + "Draft_ToggleConstructionMode", + "Draft_AddConstruction", + "Separator", + "Draft_ToggleDisplayMode", + "Draft_ToggleGrid", + "Draft_SelectPlane", + "Draft_WorkingPlaneProxy", + "Separator", + "Draft_Heal", + "Draft_ToggleContinueMode", + "Draft_ShowSnapBar"] + + +def get_draft_utility_commands_toolbar(): + """Return the utility commands list for the toolbar.""" + return ["Draft_Layer", + "Draft_AddNamedGroup", + "Draft_AddToGroup", + "Draft_SelectGroup", + "Draft_AddConstruction", + "Draft_ToggleDisplayMode", + "Draft_WorkingPlaneProxy"] + + def get_draft_snap_commands(): """Return the snapping commands list.""" return ['Draft_Snap_Lock', @@ -130,47 +229,48 @@ def get_draft_snap_commands(): ] -def init_draft_toolbars(workbench): - """Initialize the Draft toolbars. +def init_toolbar(workbench, toolbar, cmd_list): + """Initialize a toolbar. Parameters ---------- workbench: Gui.Workbench - The workbench class on which the commands have to be available. - If called from within the `Initialize` method - of a workbench class defined inside `InitGui.py`, - it can be used as `setup_draft_toolbars(self)`. + The workbench. The commands from cmd_list must be available. + + toolbar: string + The name of the toolbar. + + cmd_list: list of strings or list of strings and tuples + See f.e. the return value of get_draft_drawing_commands_temp. """ - workbench.appendToolbar(QT_TRANSLATE_NOOP("Draft", - "Draft creation tools"), - get_draft_drawing_commands()) - workbench.appendToolbar(QT_TRANSLATE_NOOP("Draft", - "Draft annotation tools"), - get_draft_annotation_commands()) - workbench.appendToolbar(QT_TRANSLATE_NOOP("Draft", - "Draft modification tools"), - get_draft_modification_commands()) + for cmd in cmd_list: + if isinstance(cmd, tuple): + if len(cmd) == 1: + workbench.appendToolbar(toolbar, [cmd[0]]) + else: + workbench.appendToolbar(toolbar, [cmd]) -def init_draft_menus(workbench): - """Initialize the Draft menus. +def init_menu(workbench, menu_list, cmd_list): + """Initialize a menu. Parameters ---------- workbench: Gui.Workbench - The workbench class on which the commands have to be available. - If called from within the `Initialize` method - of a workbench class defined inside `InitGui.py`, - it can be used as `setup_draft_menus(self)`. + The workbench. The commands from cmd_list must be available. + + menu_list: list of strings + The main and optional submenu(s). The commands, and additonal + submenus (if any), are added to the last (sub)menu in the list. + + cmd_list: list of strings or list of strings and tuples + See f.e. the return value of get_draft_drawing_commands_temp. """ - workbench.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Drafting"), - get_draft_drawing_commands()) - workbench.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Annotation"), - get_draft_annotation_commands()) - workbench.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Modification"), - get_draft_modification_commands()) - workbench.appendMenu(QT_TRANSLATE_NOOP("Draft", "&Utilities"), - get_draft_utility_commands() - + get_draft_context_commands()) + for cmd in cmd_list: + if isinstance(cmd, tuple): + if len(cmd) == 2: + workbench.appendMenu(menu_list + cmd[0], cmd[1]) + else: + workbench.appendMenu(menu_list, [cmd]) ## @} From 19084494e84eb77c8082b7be0b84dbd0eb0f2ac2 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sat, 2 Oct 2021 09:42:49 +0200 Subject: [PATCH 3/6] Update init_tools.py Removed the temp code. Changed the order of the functions. Only one item per line to make the lists more legible. --- src/Mod/Draft/draftutils/init_tools.py | 130 ++++++++----------------- 1 file changed, 39 insertions(+), 91 deletions(-) diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index a2c5454db1..9a5f226dff 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -36,18 +36,6 @@ from PySide.QtCore import QT_TRANSLATE_NOOP def get_draft_drawing_commands(): - """Return the drawing commands list.""" - return ["Draft_Line", "Draft_Wire", "Draft_Fillet", - "Draft_ArcTools", - "Draft_Circle", "Draft_Ellipse", "Draft_Rectangle", - "Draft_Polygon", "Draft_BSpline", "Draft_BezierTools", - "Draft_Point", "Draft_Facebinder", - "Draft_ShapeString","Draft_Hatch"] - - -# This function replaces get_draft_drawing_commands. -# The "_temp" suffix should be removed when the BIM Workbench has been updated. -def get_draft_drawing_commands_temp(): """Return the drawing commands list.""" from draftguitools import gui_arcs from draftguitools import gui_beziers @@ -76,53 +64,13 @@ def get_draft_drawing_commands_temp(): def get_draft_annotation_commands(): """Return the annotation commands list.""" - return ["Draft_Text", "Draft_Dimension", - "Draft_Label", "Draft_AnnotationStyleEditor"] - - -def get_draft_array_commands(): - """Return the array commands list.""" - return ["Draft_ArrayTools"] - - -# This function has been replaced by get_draft_utility_commands_toolbar. -# It should be removed when the BIM Workbench has been updated. -def get_draft_small_commands(): - """Return a list with only some utilities.""" - return ["Draft_Layer", - "Draft_WorkingPlaneProxy", - "Draft_ToggleDisplayMode", - "Draft_AddNamedGroup", - "Draft_AddToGroup", - "Draft_SelectGroup", - "Draft_AddConstruction"] + return ["Draft_Text", + "Draft_Dimension", + "Draft_Label", + "Draft_AnnotationStyleEditor"] def get_draft_modification_commands(): - """Return the modification commands list.""" - lst = ["Draft_Move", "Draft_Rotate", - "Draft_Scale", "Draft_Mirror", - "Draft_Offset", "Draft_Trimex", - "Draft_Stretch", - "Separator", - "Draft_Clone"] - lst += get_draft_array_commands() - lst += ["Separator", - "Draft_Edit", "Draft_SubelementHighlight", - "Separator", - "Draft_Join", "Draft_Split", - "Draft_Upgrade", "Draft_Downgrade", - "Separator", - "Draft_WireToBSpline", "Draft_Draft2Sketch", - "Draft_Slope", "Draft_FlipDimension", - "Separator", - "Draft_Shape2DView"] - return lst - - -# This function replaces get_draft_modification_commands. -# The "_temp" suffix should be removed when the BIM Workbench has been updated. -def get_draft_modification_commands_temp(): """Return the modification commands list.""" from draftguitools import gui_arrays arr_group = gui_arrays.ArrayGroup @@ -156,32 +104,6 @@ def get_draft_modification_commands_temp(): "Draft_Shape2DView"] -def get_draft_context_commands(): - """Return the context menu commands list.""" - return ["Draft_ApplyStyle", "Draft_ToggleDisplayMode", - "Draft_AddNamedGroup", "Draft_AddToGroup", "Draft_SelectGroup", - "Draft_SelectPlane", "Draft_ShowSnapBar", - "Draft_ToggleGrid", "Draft_SetStyle"] - - -def get_draft_line_commands(): - """Return the line commands list.""" - return ["Draft_UndoLine", "Draft_FinishLine", - "Draft_CloseLine"] - - -# This function has been replaced by get_draft_utility_commands_menu. -# It should be removed when the BIM Workbench has been updated. -def get_draft_utility_commands(): - """Return the utility commands list.""" - return ["Draft_Layer", - "Draft_Heal", - "Draft_ToggleConstructionMode", - "Draft_ToggleContinueMode", - "Draft_WorkingPlaneProxy", - "Draft_AddConstruction"] - - def get_draft_utility_commands_menu(): """Return the utility commands list for the menu.""" return ["Draft_SetStyle", @@ -218,15 +140,41 @@ def get_draft_utility_commands_toolbar(): def get_draft_snap_commands(): """Return the snapping commands list.""" return ['Draft_Snap_Lock', - 'Draft_Snap_Endpoint', 'Draft_Snap_Midpoint', - 'Draft_Snap_Center', 'Draft_Snap_Angle', - 'Draft_Snap_Intersection', 'Draft_Snap_Perpendicular', - 'Draft_Snap_Extension', 'Draft_Snap_Parallel', - 'Draft_Snap_Special', 'Draft_Snap_Near', - 'Draft_Snap_Ortho', 'Draft_Snap_Grid', - 'Draft_Snap_WorkingPlane', 'Draft_Snap_Dimensions', - 'Separator', 'Draft_ToggleGrid' - ] + 'Draft_Snap_Endpoint', + 'Draft_Snap_Midpoint', + 'Draft_Snap_Center', + 'Draft_Snap_Angle', + 'Draft_Snap_Intersection', + 'Draft_Snap_Perpendicular', + 'Draft_Snap_Extension', + 'Draft_Snap_Parallel', + 'Draft_Snap_Special', + 'Draft_Snap_Near', + 'Draft_Snap_Ortho', + 'Draft_Snap_Grid', + 'Draft_Snap_WorkingPlane', + 'Draft_Snap_Dimensions', + 'Separator', 'Draft_ToggleGrid'] + + +def get_draft_context_commands(): + """Return the context menu commands list.""" + return ["Draft_ApplyStyle", + "Draft_ToggleDisplayMode", + "Draft_AddNamedGroup", + "Draft_AddToGroup", + "Draft_SelectGroup", + "Draft_SelectPlane", + "Draft_ShowSnapBar", + "Draft_ToggleGrid", + "Draft_SetStyle"] + + +def get_draft_line_commands(): + """Return the line commands list.""" + return ["Draft_UndoLine", + "Draft_FinishLine", + "Draft_CloseLine"] def init_toolbar(workbench, toolbar, cmd_list): From 9687262cfcd6f2184e82274eb72ffa31ccad67ba Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sat, 2 Oct 2021 09:44:01 +0200 Subject: [PATCH 4/6] Update InitGui.py Removed temp code. --- src/Mod/Draft/InitGui.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/Mod/Draft/InitGui.py b/src/Mod/Draft/InitGui.py index ced2528c63..1952d50e0c 100644 --- a/src/Mod/Draft/InitGui.py +++ b/src/Mod/Draft/InitGui.py @@ -92,15 +92,9 @@ class DraftWorkbench(FreeCADGui.Workbench): # Set up command lists import draftutils.init_tools as it - if hasattr(it, "get_draft_drawing_commands_temp"): - self.drawing_commands = it.get_draft_drawing_commands_temp() - else: - self.drawing_commands = it.get_draft_drawing_commands() + self.drawing_commands = it.get_draft_drawing_commands() self.annotation_commands = it.get_draft_annotation_commands() - if hasattr(it, "get_draft_modification_commands_temp"): - self.modification_commands = it.get_draft_modification_commands_temp() - else: - self.modification_commands = it.get_draft_modification_commands() + self.modification_commands = it.get_draft_modification_commands() 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() From d6b7ab69378c421e10d6ab8d6b5df930f60c0156 Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Sat, 2 Oct 2021 09:45:22 +0200 Subject: [PATCH 5/6] Update InitGui.py Updated to use the new Draft code. --- src/Mod/Arch/InitGui.py | 152 ++++++++++++++++++++++++++++------------ 1 file changed, 107 insertions(+), 45 deletions(-) diff --git a/src/Mod/Arch/InitGui.py b/src/Mod/Arch/InitGui.py index 1c40171a93..99df49632b 100644 --- a/src/Mod/Arch/InitGui.py +++ b/src/Mod/Arch/InitGui.py @@ -51,37 +51,83 @@ class ArchWorkbench(FreeCADGui.Workbench): import Draft_rc import DraftTools import DraftGui - from draftguitools import gui_circulararray - from draftguitools import gui_polararray - from draftguitools import gui_orthoarray - from draftguitools import gui_arrays import Arch_rc import Arch + from ArchStructure import _ArchStructureGroupCommand + from ArchAxis import _ArchAxisGroupCommand + from ArchPanel import CommandPanelGroup + from ArchMaterial import _ArchMaterialToolsCommand + from ArchPipe import _ArchPipeGroupCommand + + stru_group = _ArchStructureGroupCommand + axis_group = _ArchAxisGroupCommand + pan_group = CommandPanelGroup + mat_group = _ArchMaterialToolsCommand + pipe_group = _ArchPipeGroupCommand + # Set up command lists - self.archtools = ["Arch_Wall", "Arch_StructureTools", "Arch_Rebar", - "Arch_CurtainWall","Arch_BuildingPart", - "Arch_Project", "Arch_Site", "Arch_Building", - "Arch_Floor", "Arch_Reference", - "Arch_Window", "Arch_Roof", "Arch_AxisTools", - "Arch_SectionPlane", "Arch_Space", "Arch_Stairs", - "Arch_PanelTools", "Arch_Equipment", - "Arch_Frame", "Arch_Fence", "Arch_Truss", - "Arch_Profile","Arch_MaterialTools", - "Arch_Schedule", "Arch_PipeTools", - "Arch_CutPlane", "Arch_CutLine", - "Arch_Add", "Arch_Remove", "Arch_Survey"] - self.utilities = ["Arch_Component", "Arch_CloneComponent", - "Arch_SplitMesh", "Arch_MeshToShape", - "Arch_SelectNonSolidMeshes", "Arch_RemoveShape", - "Arch_CloseHoles", "Arch_MergeWalls", "Arch_Check", - "Arch_ToggleIfcBrepFlag", "Arch_3Views", - "Arch_IfcSpreadsheet", "Arch_ToggleSubs"] + self.archtools = ["Arch_Wall", + ([QT_TRANSLATE_NOOP("Arch", "Structure tools")], + list(stru_group.GetCommands(stru_group))), # tuple len=2: submenu + ("Arch_StructureTools", ), # tuple len=1: toolbar flyout + "Arch_Rebar_Submenu", # will be replaced or removed + "Arch_Rebar", # may be replaced + "Arch_CurtainWall", + "Arch_BuildingPart", + "Arch_Project", + "Arch_Site", + "Arch_Building", + "Arch_Floor", + "Arch_Reference", + "Arch_Window", + "Arch_Roof", + ([QT_TRANSLATE_NOOP("Arch", "Axis tools")], + list(axis_group.GetCommands(axis_group))), + ("Arch_AxisTools", ), + "Arch_SectionPlane", + "Arch_Space", + "Arch_Stairs", + ([QT_TRANSLATE_NOOP("Arch", "Panel tools")], + list(pan_group.GetCommands(pan_group))), + ("Arch_PanelTools", ), + "Arch_Equipment", + "Arch_Frame", + "Arch_Fence", + "Arch_Truss", + "Arch_Profile", + ([QT_TRANSLATE_NOOP("Arch", "Material tools")], + list(mat_group.GetCommands(mat_group))), + ("Arch_MaterialTools", ), + "Arch_Schedule", + ([QT_TRANSLATE_NOOP("Arch", "Pipe tools")], + list(pipe_group.GetCommands(pipe_group))), + ("Arch_PipeTools", ), + "Arch_CutPlane", + "Arch_CutLine", + "Arch_Add", + "Arch_Remove", + "Arch_Survey"] + + self.utilities = ["Arch_Component", + "Arch_CloneComponent", + "Arch_SplitMesh", + "Arch_MeshToShape", + "Arch_SelectNonSolidMeshes", + "Arch_RemoveShape", + "Arch_CloseHoles", + "Arch_MergeWalls", + "Arch_Check", + "Arch_ToggleIfcBrepFlag", + "Arch_3Views", + "Arch_IfcSpreadsheet", + "Arch_ToggleSubs"] # Add the rebar tools from the Reinforcement addon, if available try: import RebarTools except Exception: + del self.archtools[3] # remove "Arch_Rebar_Submenu" pass else: class RebarGroupCommand: @@ -97,42 +143,58 @@ class ArchWorkbench(FreeCADGui.Workbench): def IsActive(self): return not FreeCAD.ActiveDocument is None FreeCADGui.addCommand('Arch_RebarTools', RebarGroupCommand()) - self.archtools[2] = "Arch_RebarTools" + self.archtools[3] = ([QT_TRANSLATE_NOOP("Arch", "Rebar tools")], + RebarTools.RebarCommands + ["Arch_Rebar"]) + self.archtools[4] = ("Arch_RebarTools", ) # Set up Draft command lists import draftutils.init_tools as it self.draft_drawing_commands = it.get_draft_drawing_commands() self.draft_annotation_commands = it.get_draft_annotation_commands() self.draft_modification_commands = it.get_draft_modification_commands() + self.draft_utility_commands = it.get_draft_utility_commands_menu() self.draft_context_commands = it.get_draft_context_commands() self.draft_line_commands = it.get_draft_line_commands() - self.draft_utility_commands = it.get_draft_utility_commands() # Set up toolbars - self.appendToolbar(QT_TRANSLATE_NOOP("Workbench", "Arch tools"), self.archtools) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), self.draft_drawing_commands) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), self.draft_annotation_commands) - self.appendToolbar(QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), self.draft_modification_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Workbench", "Arch tools"), + self.archtools) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft creation tools"), + self.draft_drawing_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft annotation tools"), + self.draft_annotation_commands) + it.init_toolbar(self, + QT_TRANSLATE_NOOP("Draft", "Draft modification tools"), + self.draft_modification_commands) # Set up menus - self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Arch"), - QT_TRANSLATE_NOOP("arch", "Utilities")], - self.utilities) - self.appendMenu(QT_TRANSLATE_NOOP("arch", "&Arch"), self.archtools) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Arch"), + QT_TRANSLATE_NOOP("Arch", "Utilities")], + self.utilities) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Arch")], + self.archtools) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Draft"), + QT_TRANSLATE_NOOP("Arch", "Creation")], + self.draft_drawing_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Draft"), + QT_TRANSLATE_NOOP("Arch", "Annotation")], + self.draft_annotation_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Draft"), + QT_TRANSLATE_NOOP("Arch", "Modification")], + self.draft_modification_commands) + it.init_menu(self, + [QT_TRANSLATE_NOOP("Arch", "&Draft"), + QT_TRANSLATE_NOOP("Arch", "Utilities")], + self.draft_utility_commands) - self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), - QT_TRANSLATE_NOOP("arch", "Creation")], - self.draft_drawing_commands) - self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), - QT_TRANSLATE_NOOP("arch", "Annotation")], - self.draft_annotation_commands) - self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), - QT_TRANSLATE_NOOP("arch", "Modification")], - self.draft_modification_commands) - self.appendMenu([QT_TRANSLATE_NOOP("arch", "&Draft"), - QT_TRANSLATE_NOOP("arch", "Utilities")], - self.draft_utility_commands - + self.draft_context_commands) FreeCADGui.addIconPath(":/icons") FreeCADGui.addLanguagePath(":/translations") From ff24678a7c7ab063acf5e7020bcfb1d0682bdb1d Mon Sep 17 00:00:00 2001 From: Roy-043 <70520633+Roy-043@users.noreply.github.com> Date: Tue, 5 Oct 2021 13:38:43 +0200 Subject: [PATCH 6/6] Update init_tools.py Removed "_temp" from docstrings. --- src/Mod/Draft/draftutils/init_tools.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Mod/Draft/draftutils/init_tools.py b/src/Mod/Draft/draftutils/init_tools.py index 9a5f226dff..520e54a72c 100644 --- a/src/Mod/Draft/draftutils/init_tools.py +++ b/src/Mod/Draft/draftutils/init_tools.py @@ -189,7 +189,7 @@ def init_toolbar(workbench, toolbar, cmd_list): The name of the toolbar. cmd_list: list of strings or list of strings and tuples - See f.e. the return value of get_draft_drawing_commands_temp. + See f.e. the return value of get_draft_drawing_commands. """ for cmd in cmd_list: if isinstance(cmd, tuple): @@ -212,7 +212,7 @@ def init_menu(workbench, menu_list, cmd_list): submenus (if any), are added to the last (sub)menu in the list. cmd_list: list of strings or list of strings and tuples - See f.e. the return value of get_draft_drawing_commands_temp. + See f.e. the return value of get_draft_drawing_commands. """ for cmd in cmd_list: if isinstance(cmd, tuple):