Draft: move Draft_Heal to gui_heal module

This commit is contained in:
vocx-fc
2020-03-16 19:56:14 -06:00
committed by Yorik van Havre
parent df3a06399b
commit 28e2e20a00
4 changed files with 80 additions and 20 deletions

View File

@@ -100,6 +100,7 @@ SET(Draft_GUI_tools
draftguitools/gui_togglemodes.py
draftguitools/gui_groups.py
draftguitools/gui_grid.py
draftguitools/gui_heal.py
draftguitools/README.md
)

View File

@@ -86,6 +86,7 @@ from draftguitools.gui_togglemodes import ToggleDisplayMode
from draftguitools.gui_groups import AddToGroup
from draftguitools.gui_groups import SelectGroup
from draftguitools.gui_grid import ToggleGrid
from draftguitools.gui_heal import Heal
# import DraftFillet
import drafttaskpanels.task_shapestring as task_shapestring
import drafttaskpanels.task_scale as task_scale
@@ -4705,24 +4706,6 @@ class Draft_Clone(Modifier):
ToDo.delay(FreeCADGui.runCommand, "Draft_Move")
class Heal():
"""The Draft Heal command definition"""
def GetResources(self):
return {'Pixmap' : 'Draft_Heal',
'MenuText': QtCore.QT_TRANSLATE_NOOP("Draft_Heal", "Heal"),
'ToolTip' : QtCore.QT_TRANSLATE_NOOP("Draft_Heal", "Heal faulty Draft objects saved from an earlier FreeCAD version")}
def Activated(self):
s = FreeCADGui.Selection.getSelection()
FreeCAD.ActiveDocument.openTransaction("Heal")
if s:
Draft.heal(s)
else:
Draft.heal()
FreeCAD.ActiveDocument.commitTransaction()
class Draft_Facebinder(Creator):
"""The Draft Facebinder command definition"""
@@ -5312,7 +5295,6 @@ FreeCADGui.addCommand('Draft_Clone',Draft_Clone())
FreeCADGui.addCommand('Draft_PathArray',PathArray())
FreeCADGui.addCommand('Draft_PathLinkArray',PathLinkArray())
FreeCADGui.addCommand('Draft_PointArray',PointArray())
FreeCADGui.addCommand('Draft_Heal',Heal())
FreeCADGui.addCommand('Draft_Mirror',Mirror())
FreeCADGui.addCommand('Draft_Slope',Draft_Slope())
FreeCADGui.addCommand('Draft_Stretch',Stretch())

View File

@@ -0,0 +1,76 @@
# ***************************************************************************
# * (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net> *
# * (c) 2009, 2010 Ken Cline <cline@frii.com> *
# * (c) 2020 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
# * *
# * 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 the Draft_Heal command to heal older Draft files."""
## @package gui_health
# \ingroup DRAFT
# \brief Provides the Draft_Heal command to heal older Draft files.
from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCADGui as Gui
import Draft
import draftguitools.gui_base as gui_base
from draftutils.translate import _tr
class Heal(gui_base.GuiCommandSimplest):
"""The Draft Heal command definition.
Heal faulty Draft objects saved with an earlier version of the program.
It inherits `GuiCommandSimplest` to set up the document
and other behavior. See this class for more information.
"""
def __init__(self):
super().__init__(name=_tr("Heal"))
def GetResources(self):
"""Set icon, menu and tooltip."""
_tip = ("Heal faulty Draft objects saved with an earlier version "
"of the program.\n"
"If an object is selected it will try to heal that object "
"in particular,\n"
"otherwise it will try to heal all objects "
"in the active document.")
return {'Pixmap': 'Draft_Heal',
'MenuText': QT_TRANSLATE_NOOP("Draft_Heal", "Heal"),
'ToolTip': QT_TRANSLATE_NOOP("Draft_Heal", _tip)}
def Activated(self):
"""Execute when the command is called."""
super().Activated()
s = Gui.Selection.getSelection()
self.doc.openTransaction("Heal")
if s:
Draft.heal(s)
else:
Draft.heal()
self.doc.commitTransaction()
Gui.addCommand('Draft_Heal', Heal())

View File

@@ -63,7 +63,8 @@ def get_draft_small_commands():
"Draft_WorkingPlaneProxy",
"Draft_ToggleDisplayMode",
"Draft_AddToGroup",
"Draft_SelectGroup"]
"Draft_SelectGroup",
"Draft_Heal"]
def get_draft_modification_commands():