Draft: gui_polararray cleanup

Small spacing fixes like imports in separate lines
for more clarity, the module docstrings,
and the position of the license.

Remove unnecessary check for the graphical interface
as this command should be imported when the interface
is already up and running.

Use proper `ToDo` class instead of importing `DraftGui`.
This commit is contained in:
vocx-fc
2020-03-02 18:48:34 -06:00
committed by Yorik van Havre
parent aad2969a28
commit 3e77ded2c4

View File

@@ -1,9 +1,3 @@
"""This module provides the Draft PolarArray tool.
"""
## @package gui_polararray
# \ingroup DRAFT
# \brief This module provides the Draft PolarArray tool.
# ***************************************************************************
# * (c) 2019 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
# * *
@@ -26,41 +20,28 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the Draft PolarArray tool."""
## @package gui_polararray
# \ingroup DRAFT
# \brief This module provides the Draft PolarArray tool.
from pivy import coin
from PySide.QtCore import QT_TRANSLATE_NOOP
import FreeCAD as App
import FreeCADGui as Gui
import Draft
import DraftGui
import Draft_rc
from . import gui_base
from draftguitools import gui_base
from drafttaskpanels import task_polararray
import draftutils.todo as todo
if App.GuiUp:
from PySide.QtCore import QT_TRANSLATE_NOOP
# import DraftTools
from DraftGui import translate
# from DraftGui import displayExternal
from pivy import coin
else:
def QT_TRANSLATE_NOOP(context, text):
return text
def translate(context, text):
return text
def _tr(text):
"""Function to translate with the context set"""
return translate("Draft", text)
# So the resource file doesn't trigger errors from code checkers (flake8)
# The module is used to prevent complaints from code checkers (flake8)
True if Draft_rc.__name__ else False
class GuiCommandPolarArray(gui_base.GuiCommandBase):
"""Gui command for the PolarArray tool"""
"""Gui command for the PolarArray tool."""
def __init__(self):
super().__init__()
@@ -74,6 +55,7 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
self.point = App.Vector()
def GetResources(self):
"""Set icon, menu and tooltip."""
_msg = ("Creates copies of a selected object, "
"and places the copies in a polar pattern.\n"
"The properties of the array can be further modified after "
@@ -85,7 +67,7 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
return d
def Activated(self):
"""This is called when the command is executed.
"""Execute when the command is called.
We add callbacks that connect the 3D view with
the widgets of the task panel.
@@ -103,10 +85,10 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
# of the interface, to be able to call a function from within it.
self.ui.source_command = self
# Gui.Control.showDialog(self.ui)
DraftGui.todo.delay(Gui.Control.showDialog, self.ui)
todo.ToDo.delay(Gui.Control.showDialog, self.ui)
def move(self, event_cb):
"""This is a callback for when the mouse pointer moves in the 3D view.
"""Execute as a callback when the pointer moves in the 3D view.
It should automatically update the coordinates in the widgets
of the task panel.
@@ -119,7 +101,7 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
self.ui.display_point(self.point)
def click(self, event_cb=None):
"""This is a callback for when the mouse pointer clicks on the 3D view.
"""Execute as a callback when the pointer clicks on the 3D view.
It should act as if the Enter key was pressed, or the OK button
was pressed in the task panel.
@@ -136,7 +118,7 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
self.ui.accept()
def completed(self):
"""This is called when the command is terminated.
"""Execute when the command is terminated.
We should remove the callbacks that were added to the 3D view
and then close the task panel.
@@ -146,10 +128,8 @@ class GuiCommandPolarArray(gui_base.GuiCommandBase):
self.view.removeEventCallbackPivy(self.mouse_event,
self.callback_click)
if Gui.Control.activeDialog():
Gui.Snapper.off()
Gui.Control.closeDialog()
super().finish()
if App.GuiUp:
Gui.addCommand('Draft_PolarArray', GuiCommandPolarArray())
Gui.addCommand('Draft_PolarArray', GuiCommandPolarArray())