FreeCAD
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# @{
32from PySide.QtCore import QT_TRANSLATE_NOOP33
34import FreeCADGui as Gui35import Draft_rc36import draftguitools.gui_arcs as gui_arcs37
38# The module is used to prevent complaints from code checkers (flake8)
39True if Draft_rc.__name__ else False40
41
42class Circle(gui_arcs.Arc):43"""Gui command for the Circle tool.44
45It inherits the entire `Arc` class.
46The only difference is that the `closedCircle` attribute
47is already set to `True`, and the `featureName` attribute
48is `'Circle'`.
49
50This will result in an arc that describes a complete circumference
51so the starting angle and end angle will be the same.
52
53Internally, both circular arcs and circles are `'Circle'` objects.
54
55Discussion
56----------
57Both arcs and circles are `'Circle'` objects, but when it comes to the
58Gui Commands, the relationships are reversed, and both launch the `Arc`
59command.
60
61Maybe the relationship should be changed: the base Gui Command
62should be `Circle`, and an arc would launch the same command,
63as both are internally `'Circle'` objects.
64
65Another possibility is to rename the `'Circle'` object to `'Arc'`.
66Then both a circle and an arc would internally be `'Arc'` objects,
67and in the Gui Commands they both would use the `Arc` command.
68"""
69
70def __init__(self):71super().__init__()72self.closedCircle = True73self.featureName = "Circle"74
75def GetResources(self):76"""Set icon, menu and tooltip."""77
78return {'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
84Gui.addCommand('Draft_Circle', Circle())85
86## @}
87