FreeCAD

Форк
0
/
gui_circles.py 
86 строк · 3.8 Кб
1
# ***************************************************************************
2
# *   (c) 2009, 2010 Yorik van Havre <yorik@uncreated.net>                  *
3
# *   (c) 2009, 2010 Ken Cline <cline@frii.com>                             *
4
# *   (c) 2020 Eliud Cabrera Castillo <e.cabrera-castillo@tum.de>           *
5
# *                                                                         *
6
# *   This file is part of the FreeCAD CAx development system.              *
7
# *                                                                         *
8
# *   This program is free software; you can redistribute it and/or modify  *
9
# *   it under the terms of the GNU Lesser General Public License (LGPL)    *
10
# *   as published by the Free Software Foundation; either version 2 of     *
11
# *   the License, or (at your option) any later version.                   *
12
# *   for detail see the LICENCE text file.                                 *
13
# *                                                                         *
14
# *   FreeCAD is distributed in the hope that it will be useful,            *
15
# *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
16
# *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
17
# *   GNU Library General Public License for more details.                  *
18
# *                                                                         *
19
# *   You should have received a copy of the GNU Library General Public     *
20
# *   License along with FreeCAD; if not, write to the Free Software        *
21
# *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
22
# *   USA                                                                   *
23
# *                                                                         *
24
# ***************************************************************************
25
"""Provides GUI tools to create Circle objects."""
26
## @package gui_circles
27
# \ingroup draftguitools
28
# \brief Provides GUI tools to create Circle objects.
29

30
## \addtogroup draftguitools
31
# @{
32
from PySide.QtCore import QT_TRANSLATE_NOOP
33

34
import FreeCADGui as Gui
35
import Draft_rc
36
import draftguitools.gui_arcs as gui_arcs
37

38
# The module is used to prevent complaints from code checkers (flake8)
39
True if Draft_rc.__name__ else False
40

41

42
class Circle(gui_arcs.Arc):
43
    """Gui command for the Circle tool.
44

45
    It inherits the entire `Arc` class.
46
    The only difference is that the `closedCircle` attribute
47
    is already set to `True`, and the `featureName` attribute
48
    is `'Circle'`.
49

50
    This will result in an arc that describes a complete circumference
51
    so the starting angle and end angle will be the same.
52

53
    Internally, both circular arcs and circles are `'Circle'` objects.
54

55
    Discussion
56
    ----------
57
    Both arcs and circles are `'Circle'` objects, but when it comes to the
58
    Gui Commands, the relationships are reversed, and both launch the `Arc`
59
    command.
60

61
    Maybe the relationship should be changed: the base Gui Command
62
    should be `Circle`, and an arc would launch the same command,
63
    as both are internally `'Circle'` objects.
64

65
    Another possibility is to rename the `'Circle'` object to `'Arc'`.
66
    Then both a circle and an arc would internally be `'Arc'` objects,
67
    and in the Gui Commands they both would use the `Arc` command.
68
    """
69

70
    def __init__(self):
71
        super().__init__()
72
        self.closedCircle = True
73
        self.featureName = "Circle"
74

75
    def GetResources(self):
76
        """Set icon, menu and tooltip."""
77

78
        return {'Pixmap': 'Draft_Circle',
79
                'Accel': "C, I",
80
                'MenuText': QT_TRANSLATE_NOOP("Draft_Circle", "Circle"),
81
                'ToolTip': QT_TRANSLATE_NOOP("Draft_Circle", "Creates a circle (full circular arc).\nCTRL to snap, ALT to select tangent objects.")}
82

83

84
Gui.addCommand('Draft_Circle', Circle())
85

86
## @}
87

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.