Skip to content

Commit

Permalink
Draft: correct description of draftutils package
Browse files Browse the repository at this point in the history
These utilities are general in the entire workbench,
some of them can be used without a GUI, and some of them
absolutely require the GUI to function.
  • Loading branch information
vocx-fc authored and yorikvanhavre committed May 6, 2020
1 parent 58dc5c6 commit fee81e8
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 11 deletions.
19 changes: 12 additions & 7 deletions src/Mod/Draft/draftutils/README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
2020 February
2020 May

These files provide auxiliary functions used by the Draft workbench.
Previously most of these were in `Draft.py`, `DraftTools.py`
and `DraftGui.py`.

Previously most of these functions were defined in `Draft.py`,
`DraftTools.py`, and `DraftGui.py`. However, due to being defined in these
big modules, it was impossible to use them individually without importing
the entire modules. So a decision was made to split the functions
into smaller modules.

In here we want modules with generic functions that can be used everywhere
in the workbench. We want these tools to depend only on standard modules
so that there are no circular dependencies, and so that they can be used
by all functions and graphical commands in this workbench
and possibly other workbenches.
in the workbench. We want these tools to depend only on standard Python
modules and basic FreeCAD methods so that there are no circular dependencies,
and so that they can be used by all functions and graphical commands
in this workbench, and others if possible.
- `utils`: basic functions
- `messages`: used to print messages
- `translate`: used to translate texts
Expand All @@ -18,6 +22,7 @@ and possibly other workbenches.
Some auxiliary functions require that the graphical interface is loaded
as they deal with scripted objects' view providers or the 3D view.
- `gui_utils`: basic functions dealing with the graphical interface
- `init_draft_statusbar`: functions to initialize the status bar

For more information see the thread:
[[Discussion] Splitting Draft tools into their own modules](https://forum.freecadweb.org/viewtopic.php?f=23&t=38593&start=10#p341298)
52 changes: 48 additions & 4 deletions src/Mod/Draft/draftutils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,50 @@
"""Utility functions that do not require the graphical user interface.
# ***************************************************************************
# * (c) 2019 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 *
# * *
# ***************************************************************************
"""Utility modules that are used throughout the workbench.
These functions are used throughout the Draft Workbench.
They can be called from any module, whether it uses the graphical
user interface or not.
These modules include functions intended to be quite general,
so they should be useful in all other modules in the workbench
and even other workbenches.
Since they are not meant to be very complex, they shouldn't require
a lot of prerequisites, and shouldn't cause problems of circular imports.
They include modules that don't require the graphical interface (GUI),
as well as functions that do require it because they interact
with the view providers or with the 3D view.
Non GUI modules
---------------
- `utils`, generic functions
- `messages`, shorthands to print to the console
- `translate`, translate text using QtCore
GUI modules
-----------
- `gui_utils`, generic functions that deal with the graphical interface
- `todo`, delay execution of Python code through Qt
Initialization modules for the GUI
----------------------------------
- `init_tools`, initialize toolbars and menus of the workbench
- `init_draft_statusbar`, initialize the status bar of the workbench
"""

0 comments on commit fee81e8

Please sign in to comment.