Skip to content

Commit

Permalink
Draft: gui_circulararray cleanup
Browse files Browse the repository at this point in the history
Small spacing fixes like imports in separate lines
for more clarity, the module docstring,
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`.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed Apr 7, 2020
1 parent 43c93b8 commit dd9b694
Showing 1 changed file with 18 additions and 38 deletions.
56 changes: 18 additions & 38 deletions src/Mod/Draft/draftguitools/gui_circulararray.py
@@ -1,9 +1,3 @@
"""This module provides the Draft CircularArray tool.
"""
## @package gui_circulararray
# \ingroup DRAFT
# \brief This module provides the Draft CircularArray tool.

# ***************************************************************************
# * (c) 2019 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de> *
# * *
Expand All @@ -26,41 +20,28 @@
# * USA *
# * *
# ***************************************************************************
"""Provides the Draft CircularArray tool."""
## @package gui_circulararray
# \ingroup DRAFT
# \brief This module provides the Draft CircularArray 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_circulararray
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 GuiCommandCircularArray(gui_base.GuiCommandBase):
"""Gui command for the CircularArray tool"""
"""Gui command for the CircularArray tool."""

def __init__(self):
super().__init__()
Expand All @@ -74,6 +55,7 @@ def __init__(self):
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 circular pattern.\n"
"The properties of the array can be further modified after "
Expand All @@ -85,7 +67,7 @@ def GetResources(self):
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.
Expand All @@ -103,10 +85,10 @@ def Activated(self):
# 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.
Expand All @@ -119,7 +101,7 @@ def move(self, event_cb):
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.
Expand All @@ -136,7 +118,7 @@ def click(self, event_cb=None):
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.
Expand All @@ -146,10 +128,8 @@ def completed(self):
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_CircularArray', GuiCommandCircularArray())
Gui.addCommand('Draft_CircularArray', GuiCommandCircularArray())

0 comments on commit dd9b694

Please sign in to comment.